Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const EtherPortClient = require("etherport-client").EtherPortClient;
- const Firmata = require("firmata");
- const five = require("johnny-five");
- const board = new five.Board({
- io: new Firmata(new EtherPortClient({
- host: "10.0.1.4", // CHANGE TO YOUR IP ADDRESS
- port: 3030
- }))
- });
- board.on("ready", function() {
- var accelerometer = new five.Accelerometer({
- controller: "ADXL345",
- // Optionally set the range to one of
- // 2, 4, 8, 16 (±g)
- // Defaults to ±2g
- // range: ...
- });
- accelerometer.on("change", function() {
- console.log("accelerometer");
- console.log(" x : ", this.x);
- console.log(" y : ", this.y);
- console.log(" z : ", this.z);
- console.log(" pitch : ", this.pitch);
- console.log(" roll : ", this.roll);
- console.log(" acceleration : ", this.acceleration);
- console.log(" inclination : ", this.inclination);
- console.log(" orientation : ", this.orientation);
- console.log("--------------------------------------");
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement