A simple "Christmas light" prototype, created with Intel Edison Board, Arduino, LEDs, Intel XDK IoT Edition IDE, NodeJS.
I essentially tweaked the Groove LED - Template NodeJS code to achieve this. Just a play really!
See this YouTube demo.
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the Grove LED object using GPIO pin 2, 3, 4
var led2 = new groveSensor.GroveLed(2); // red
var led3 = new groveSensor.GroveLed(3); // blue
var led4 = new groveSensor.GroveLed(4); //green
// Print the name
console.log(led2.name());
console.log(led3.name());
console.log(led4.name());
// cycle through 300 times, pausing 100 milli-seconds.
// between transitions
var i = 0;
var waiting = setInterval(function() {
if ( i % 3 == 0 ) {
led2.on(); // red on
led3.off();
led4.off();
}
else if ( i % 3 == 1 ) {
led2.off();
led3.on(); // blue on
led4.off();
} else {
led2.off();
led3.off();
led4.on(); // green on
}
i++;
if ( i == 300 ) {
led2.off();
led3.off();
led4.off();
clearInterval(waiting);
}
}, 100); // reduce this number for more frequent flash :)