Skip to content

Instantly share code, notes, and snippets.

@andrewn
Created January 3, 2016 17:08
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 andrewn/e7bdbe73e39cf940cb20 to your computer and use it in GitHub Desktop.
Save andrewn/e7bdbe73e39cf940cb20 to your computer and use it in GitHub Desktop.
Testing jonnny-five button class with internal pull up resistor
var five = require('johnny-five'),
RaspiIO = require('raspi-io');
var board;
board = new five.Board({
io: new RaspiIO(),
repl: true
});
board.on('ready', function() {
button = new five.Button({
pin: 0,
isPullup: true
});
var led = new five.Led(26);
button.on('press', function () {
console.log('press');
led.on();
});
button.on('release', function () {
console.log('release');
led.off();
});
button.on('hold', function () {
console.log('hold');
led.toggle();
});
this.repl.inject({ io: this.io, led: led, button: button });
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment