Skip to content

Instantly share code, notes, and snippets.

@BrianGenisio
Created January 17, 2017 02:39
Show Gist options
  • Save BrianGenisio/3b5b8e4c5813c55640e3785d4060281a to your computer and use it in GitHub Desktop.
Save BrianGenisio/3b5b8e4c5813c55640e3785d4060281a to your computer and use it in GitHub Desktop.
Code to use the Feather Huzzah with the ADXL345
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("--------------------------------------");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment