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("--------------------------------------");
});
});
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.