Last active
August 29, 2015 14:02
-
-
Save Resseguie/a573533abb98fcf52210 to your computer and use it in GitHub Desktop.
demo basic LED digital methods
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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