johnny-five-electron
Version:
Temporary fork to support Electron (to be deprecated)
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