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

Breadboard for "Expander - MUXSHIELD2, Analog Sensors"

expander-MUXSHIELD2-analog-read.png

Fritzing diagram: 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);
  });
});

 

Component Classes in this example:

Hi! The Johnny-Five community is building new projects every day. We made this newsletter to tell you about what's new, what's good, and what's next for Open Source robotics. Join us in exploring what we can make together.

Fork me on GitHub