Skip to content

Instantly share code, notes, and snippets.

@Resseguie
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Resseguie/cb9b8a2ac2a744bdce16 to your computer and use it in GitHub Desktop.
Save Resseguie/cb9b8a2ac2a744bdce16 to your computer and use it in GitHub Desktop.
Demonstrates button (isPullup true) and led together
var five = require("johnny-five"),
button, led;
five.Board().on("ready", function() {
led = new five.Led(4);
setInterval(function() {
led.toggle();
}, 100);
button = new five.Button({
pin: 2,
isPullup: true
});
button.on("down", function() {
console.log("down");
});
button.on("hold", function() {
console.log("hold");
});
button.on("up", function() {
console.log("up");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment