Permalink
Fetching contributors…
Cannot retrieve contributors at this time
90 lines (51 sloc) 1.51 KB

Expander - MUXSHIELD2, Analog Sensors

Using a MUXSHIELD2 Expander as a Virtual Board. Displays value of potentiometers in console graph. (npm install barcli)

Breadboard for "Expander - MUXSHIELD2, Analog Sensors"

docs/breadboard/expander-MUXSHIELD2-analog-read.png

Fritzing diagram: docs/breadboard/expander-MUXSHIELD2-analog-read.fzz

 

Run this example from the command line with:

node eg/expander-MUXSHIELD2-analog-read.js
var Barcli = require("barcli");
var five = require("johnny-five");
var board = new five.Board({
  repl: false,
  debug: false
});

board.on("ready", function() {
  var bars = {
    a: new Barcli({ label: "IO1-15", range: [0, 1023] }),
    b: new Barcli({ label: "IO2-15", range: [0, 1023] }),
  };

  var virtual = new five.Board.Virtual(
    new five.Expander("MUXSHIELD2")
  );

  var a = new five.Sensor({
    pin: "IO1-15",
    board: virtual
  });

  a.on("change", function() {
    bars.a.update(this.value);
  });

  var b = new five.Sensor({
    pin: "IO2-15",
    board: virtual
  });

  b.on("change", function() {
    bars.b.update(this.value);
  });
});

 

License

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