Skip to content

Latest commit

 

History

History
75 lines (42 loc) · 1.46 KB

accelerometer-adxl335.md

File metadata and controls

75 lines (42 loc) · 1.46 KB

Accelerometer - ADXL335

Breadboard for "Accelerometer - ADXL335"

docs/breadboard/accelerometer-adxl335.png

Fritzing diagram: docs/breadboard/accelerometer-adxl335.fzz

 

Run this example from the command line with:

node eg/accelerometer-adxl335.js
const { Accelerometer, Board } = require("johnny-five");
const board = new Board();

board.on("ready", () => {
  const accelerometer = new Accelerometer({
    controller: "ADXL335",
    pins: ["A0", "A1", "A2"]
  });

  accelerometer.on("change", () => {
    const {acceleration, inclination, orientation, pitch, roll, x, y, z} = accelerometer;
    console.log("Accelerometer:");
    console.log("  x            : ", x);
    console.log("  y            : ", y);
    console.log("  z            : ", z);
    console.log("  pitch        : ", pitch);
    console.log("  roll         : ", roll);
    console.log("  acceleration : ", acceleration);
    console.log("  inclination  : ", inclination);
    console.log("  orientation  : ", orientation);
    console.log("--------------------------------------");
  });
});

 

License

Copyright (c) 2012-2014 Rick Waldron waldron.rick@gmail.com Licensed under the MIT license. Copyright (c) 2015-2023 The Johnny-Five Contributors Licensed under the MIT license.