Skip to content

Latest commit

 

History

History
79 lines (45 loc) · 1.32 KB

compass-MAG3110.md

File metadata and controls

79 lines (45 loc) · 1.32 KB

Compass - MAG3110

Breadboard for "Compass - MAG3110"

docs/breadboard/compass-MAG3110.png

Fritzing diagram: docs/breadboard/compass-MAG3110.fzz

 

Run this example from the command line with:

node eg/compass-MAG3110.js
const { Board, Compass } = require("johnny-five");
const board = new Board();

board.on("ready", () => {
  const compass = new Compass({
    controller: "MAG3110",
    // Optionally pre-load the offsets
    offsets: {
      x: [-819, -335],
      y: [702, 1182],
      z: [-293, -13],
    },
  });

  compass.on("calibrated", offsets => {
    // Use this data with the optional "offsets" property above
    // console.log("calibrated:", offsets);
  });

  compass.on("change", () => {
    const {bearing, heading} = compass;
    console.log("Compass:");
    console.log("  bearing     : ", bearing);
    console.log("  heading     : ", heading);
    console.log("--------------------------------------");
  });
});

 

License

Copyright (c) 2012-2014 Rick Waldron [email protected] Licensed under the MIT license. Copyright (c) 2015-2023 The Johnny-Five Contributors Licensed under the MIT license.