Skip to content

Instantly share code, notes, and snippets.

@Atlas7
Last active October 17, 2015 15:15
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 Atlas7/6aa14e92b3f8fafee366 to your computer and use it in GitHub Desktop.
Save Atlas7/6aa14e92b3f8fafee366 to your computer and use it in GitHub Desktop.
Intel Groove LED Christmas Light NodeJS Script

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 :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment