Skip to content

Instantly share code, notes, and snippets.

@Protonk
Last active December 18, 2015 10:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Protonk/5769380 to your computer and use it in GitHub Desktop.
Save Protonk/5769380 to your computer and use it in GitHub Desktop.
Adjust the smoothing parameter w/ the sensor slider value.
var five = require("./lib/johnny-five.js"),
board, slider;
board = new five.Board();
board.on("ready", function() {
var accel = new five.Accelerometer({
pins: [ "I0", "I1" ],
freq: 100
});
// Create a new `slider` hardware instance.
slider = new five.Sensor("I3");
// Fires when value of sensor changes
//
slider.scale([ 0, 1 ]).on("slide", function() {
accel.alpha = this.scaled;
});
accel.on("acceleration", function(err, data) {
console.log(Math.abs(data.rough.x - data.smooth.x));
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment