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, Raspberry Pi, Spark Core, TI Launchpad and more!
18 lines (14 loc) • 384 B
JavaScript
var five = require("../lib/johnny-five.js");
var board = new five.Board();
board.on("ready", function() {
var proximity = new five.Proximity({
controller: "GP2Y0A21YK",
pin: "A0"
});
proximity.on("data", function() {
console.log(this.cm + "cm", this.in + "in");
});
proximity.on("change", function() {
console.log("The obstruction has moved.");
});
});