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!
42 lines (37 loc) • 1.06 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 moisture = new five.Sensor("A0");
// Plug the Relay module into the
// Grove Shield's D6 jack.
var relay = new five.Relay(6);
moisture.scale(0, 100).on("change", function() {
// 0 - Dry
// 50 - Wet
if (this.value < 20) {
if (!relay.isOn) {
// Turn on the water pump!
relay.on();
}
} else {
relay.off();
}
});
});
// @markdown
// For this program, you'll need:
//
// 
//
// 
//
// 
//
// 
//
// @markdown