Like Master Wong says, "this move, basic and simple". (Simple Button-triggered LED device, made with: Intel Edison Board, Groove Button and LED, Intel XDK IoT Edition, NodeJS.).
See this YouTube Demo.
/*jslint node:true, vars:true, bitwise:true, unparam:true */
/*jshint unused:true */
// Leave the above lines for propper jshinting
//Type Node.js Here :)
// Board setup
// D5: Grove Button
// D2: Grove LED - Red
// Usage
// Press the button, the LED turn on! so basic and simple :)
// Load Grove module
var groveSensor = require('jsupm_grove');
// Create the button object using GPIO pin 5
var button = new groveSensor.GroveButton(5);
// Create the Grove LED object using GPIO pin 2
var led = new groveSensor.GroveLed(2);
// Read button input. If pressed - turn LED on. Otherwise, LED off.
function readButtonValue() {
//console.log(button.name() + " value is " + button.value());
if (button.value() == 0) {
led.off();
}
else {
led.on();
}
}
setInterval(readButtonValue, 10);