UNPKG

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!

22 lines (16 loc) 452 B
var five = require("../lib/johnny-five.js"); var board = new five.Board(); board.on("ready", function() { var sonar = new five.Sonar({ device: "SRF10" }); function display(type, value, unit) { console.log("%s event: object is %d %s away", type, value, unit); } sonar.on("data", function() { display("data", this.inches, "inches"); }); sonar.on("change", function() { display("data", this.inches, "inches"); }); });