Skip to content

Instantly share code, notes, and snippets.

@alanshaw
Created July 4, 2014 04:42
Show Gist options
  • Save alanshaw/73e9cebd01b82b2e51d5 to your computer and use it in GitHub Desktop.
Save alanshaw/73e9cebd01b82b2e51d5 to your computer and use it in GitHub Desktop.
High five button
var five = require("johnny-five")
, board = new five.Board()
board.on("ready", function () {
var led = new five.Led(11)
var btn = new five.Button(4)
led.pulse(2000)
var offTimeout = null
btn.on("down", function () {
console.log("down", Date.now())
led.stop()
led.strobe(50)
clearTimeout(offTimeout)
offTimeout = setTimeout(function () {
led.stop()
led.pulse(2000)
}, 5000)
})
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment