Demonstrates using dual 7 Segment displays.

Breadboard for "LED - Digital Clock, Dual Displays"

led-digits-clock-dual.png

Fritzing diagram: led-digits-clock-dual.fzz

 

Run this example from the command line with:

node eg/led-digits-clock-dual.js
const moment = require("moment");
const { Board, Led } = require("johnny-five");

const board = new Board();

board.on("ready", () => {
  const hmm = new Led.Digits({
    controller: "HT16K33",
  });
  const seconds = new Led.Digits({
    pins: {
      data: 2,
      cs: 3,
      clock: 4,
    }
  });

  let minute = null;
  let toggle = 0;

  setInterval(() => {
    const now = moment();
    const min = now.minute();
    let form;

    if (minute !== min) {
      minute = min;
      form = (toggle ^= 1) ? "h:mm" : "hmm";
      hmm.print((" " + now.format(form)).slice(-5));
    }
    seconds.print("  " + now.format("ss.SSSS"));
  }, 200);
});

Additional Notes

Learn More:

 

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