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, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!

39 lines (30 loc) 732 B
var five = require("../lib/johnny-five.js"); var board = new five.Board(); board.on("ready", function() { // Create a new `Accelerometer` hardware instance. // // Devices: // // - Dual Axis http://tinkerkit.tihhs.nl/accelerometer/ // var accel = new five.Accelerometer({ pins: ["I0", "I1"], freq: 100 }); // Accelerometer Event API // "acceleration" // // Fires once every N ms, equal to value of freg // Defaults to 500ms // accel.on("acceleration", function() { console.log("acceleration", this.pitch, this.roll); }); // "axischange" // // Fires only when X, Y or Z has changed // accel.on("axischange", function() { console.log("axischange", this.raw); }); });