Skip to content

Instantly share code, notes, and snippets.

@Resseguie
Last active August 29, 2015 14:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Resseguie/a573533abb98fcf52210 to your computer and use it in GitHub Desktop.
Save Resseguie/a573533abb98fcf52210 to your computer and use it in GitHub Desktop.
demo basic LED digital methods
var five = require("johnny-five");
five.Board().on("ready", function() {
// Defaults to pin 13
var led = new five.Led(process.argv[2] || 13);
// Turn on the LED
console.log("led.on()");
led.on();
// strobe( rate )
// Wait 3 seconds, then start strobing the LED every 100 ms
this.wait(3000,function(){
console.log("led.strobe(100)");
led.strobe(100);
});
// stop() and off()
//
// Stop the strobing and turn the LED off.
// Note, this is 10 seconds from programm execution,
// not 10 seconds from when strobe starts.
// You would need to nest the waits or use something
// like `temporal` to be more precise in sequencing.
this.wait(10000,function(){
led.stop();
console.log("led.off()");
led.off();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment