johnny-five-electron
Version:
Temporary fork to support Electron (to be deprecated)
41 lines (36 loc) • 1.07 kB
JavaScript
var five = require("../lib/johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
io: new Edison()
});
board.on("ready", function() {
// Plug the Moisture module into the
// Grove Shield's A0 jack
var vibration = new five.Sensor("A0");
// Plug the LED module into the
// Grove Shield's D6 jack.
var led = new five.LED(6);
vibration.scale(0, 1).on("change", function() {
if (Math.round(this.value)) {
if (!led.isOn) {
// Turn on the security lights
led.on();
}
} else {
led.off();
}
});
});
// @markdown
// For this program, you'll need:
//
// 
//
// 
//
// 
//
// 
//
//
// @markdown