Skip to content

Unable to use Led.Digits with Multple Boards #1834

@chrisl8

Description

@chrisl8

I am running Johnny-Five on a Raspberry Pi connected to two Arduino Mega 3's using the Firmata.

LEDs, Buttons, Potentiometers and switches all work fine following the instructions here:
https://johnny-five.io/examples/board-multi/

However, HT16K33 Led.Digits do not. I can set up multiple boards, but only the first Led.Digits instance that I add will work, the others remain blank/off.

I am following the instructions here:
https://johnny-five.io/examples/led-digits-clock-HT16K33/
and then adding the board option, and I can use EITHER board, but if I try to add both, only the first one added works.

Here is the code I am using to test:

const { Boards, Led } = require("johnny-five");

const displays = [
  {
    id: "one",
    port: "/dev/ttyACM3",
    repl: false,
  },
  {
    id: "two",
    port: "/dev/ttyACM0",
    repl: false,
  },
];

const boards = new Boards(displays);

boards.on("ready", () => {
  // This is only here to demonstrate that both boards work
  const boardOneLED = new Led({ board: boards.byId("one"), pin: 13 });
  boardOneLED.blink(500);

  // This is only here to demonstrate that both boards work
  const boardTwoLED = new Led({ board: boards.byId("two"), pin: 13 });
  boardTwoLED.blink(500);

  // Only the first one will work, the second one added will not.
  // Reverse their order to demonstrate.
  const boardOneDigits = new Led.Digits({
    controller: "HT16K33",
    board: boards.byId("one"),
  });
  const boardTwoDigits = new Led.Digits({
    controller: "HT16K33",
    board: boards.byId("two"),
  });

  boardOneDigits.on();
  boardOneDigits.print("1111");
  boardTwoDigits.on();
  boardTwoDigits.print("2222");

  process.on("SIGINT", () => {
    console.log("Turning off displays.");
    boardOneDigits.off();
    boardTwoDigits.off();
  });
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions