UNPKG

johnny-five

Version:

The JavaScript Arduino Programming Framework.

42 lines (29 loc) 734 B
var five = require("../lib/johnny-five.js"), board, ping; board = new five.Board(); board.on("ready", function() { // Create a new `ping` hardware instance. ping = new five.Ping(7); // Properties // ping.microseconds // // Roundtrip distance in microseconds // // ping.inches // // Calculated distance to object in inches // // ping.cm // // Calculated distance to object in centimeters // // Ping Event API // "data" get the current reading from the ping ping.on("data", function(err, value) { console.log("data", value); }); ping.on("change", function(err, value) { console.log(typeof this.inches); console.log("Object is " + this.inches + "inches away"); }); });