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!

41 lines (31 loc) 769 B
var five = require("../lib/johnny-five.js"), board, accel; board = new five.Board(); board.on("ready", function() { // Create a new `Accelerometer` hardware instance. // // Devices: // // - Dual Axis http://tinkerkit.tihhs.nl/accelerometer/ // 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(err, timestamp) { console.log("acceleration", this.pitch, this.roll); }); // "axischange" // // Fires only when X, Y or Z has changed // accel.on("axischange", function(err, timestamp) { console.log("axischange", this.raw); }); });