johnny-five-electron
Version:
Temporary fork to support Electron (to be deprecated)
41 lines (36 loc) • 1.25 kB
JavaScript
var five = require("../lib/johnny-five");
var Edison = require("edison-io");
var board = new five.Board({
io: new Edison()
});
board.on("ready", function() {
// Plug the HMC5883L Compass module
// into an I2C jack
var compass = new five.Compass({
controller: "HMC5883L"
});
compass.on("headingchange", function() {
console.log("headingchange");
console.log(" heading : ", Math.floor(this.heading));
console.log(" bearing : ", this.bearing.name);
console.log("--------------------------------------");
});
compass.on("data", function() {
console.log(" heading : ", Math.floor(this.heading));
console.log(" bearing : ", this.bearing.name);
console.log("--------------------------------------");
});
});
// @markdown
// For this program, you'll need:
//
// 
//
// 
//
// 
//
// - [Grove - 3-Axis Digital Compass](http://www.seeedstudio.com/depot/Grove-3Axis-Digital-Compass-p-759.html)
//
//
// @markdown