Paul Langdon
Published

Example: LED Socket

Sample LED Socket on Intel Edison in Node.js

BeginnerProtip808
Example: LED Socket

Code

Blinking LED with Grove Socket Kit

JavaScript
// Load Grove module
var groveSensor = require('jsupm_grove');

// Create the Grove LED object using GPIO pin 2
var led = new groveSensor.GroveLed(2);

// Print the name
console.log(led.name());

// Turn the LED on and off 10 times, pausing one second
// between transitions
var i = 0;
var waiting = setInterval(function() {
        if ( i % 2 == 0 ) {
            led.on();
        } else {
            led.off();
        }
        i++;
        if ( i == 20 ) clearInterval(waiting);
        }, 1000);
            

Credits

Paul Langdon

Paul Langdon

49 projects • 317 followers
Working as a cloud architect for an IoT hardware company

Comments