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!
25 lines (18 loc) • 457 B
JavaScript
var five = require("../lib/johnny-five.js");
var board = new five.Board();
board.on("ready", function() {
// Create a new `ping` hardware instance.
var ping = new five.Ping(7);
// Properties
// ping.in/ping.inches
//
// Calculated distance to object in inches
//
// ping.cm
//
// Calculated distance to object in centimeters
//
ping.on("change", function() {
console.log("Object is " + this.in + " inches away");
});
});