Using a MUXSHIELD2 Expander as a Virtual Board. Displays value of potentiometers in console graph. (npm install barcli
)
Breadboard for "Expander - MUXSHIELD2, Analog Sensors"
Fritzing diagram: expander-MUXSHIELD2-analog-read.fzz
Run this example from the command line with:
node eg/expander-MUXSHIELD2-analog-read.js
const Barcli = require("barcli");
const { Board, Expander, Sensor } = require("johnny-five");
const board = new Board({
repl: false,
debug: false
});
board.on("ready", () => {
const range = [0, 1023];
const bars = {
a: new Barcli({ label: "IO1-15", range }),
b: new Barcli({ label: "IO2-15", range }),
};
const virtual = new Board.Virtual(
new Expander("MUXSHIELD2")
);
const a = new Sensor({
pin: "IO1-15",
board: virtual
});
a.on("change", () => {
bars.a.update(a.value);
});
const b = new Sensor({
pin: "IO2-15",
board: virtual
});
b.on("change", () => {
bars.b.update(b.value);
});
});