UNPKG

johnny-five

Version:

The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!

39 lines (30 loc) 845 B
var five = require("../lib/johnny-five.js"), board, button; board = new five.Board(); board.on("ready", function() { // Create a new `button` hardware instance. // This example allows the button module to // create a completely default instance button = new five.Button(2); // Inject the `button` hardware into // the Repl instance's context; // allows direct command line access board.repl.inject({ button: button }); // Button Event API // "down" the button is pressed button.on("down", function() { console.log("down"); }); // "hold" the button is pressed for specified time. // defaults to 500ms (1/2 second) // set button.on("hold", function() { console.log("hold"); }); // "up" the button is released button.on("up", function() { console.log("up"); }); });