johnny-five
Version:
The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!
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