Arduino library · Displays

DigitLedDisplay: an example that runs

Yes. You can use the DigitLedDisplay library online in Mokxi with nothing to install, and the sketch runs in your browser against the simulated part (Eight-digit display, MAX7219). The example below, "Numbers on an eight-digit MAX7219 board", runs on the Arduino Uno R3.

Built in on Mokxi: #include <DigitLedDisplay.h> and it builds, with nothing to install. Free, and no account needed.

What DigitLedDisplay does

Numbers on the MAX7219 eight-digit board: setBright(), setDigitLimit(), printDigit() at any starting digit, raw write(), on(), off() and clear(). That is what DigitLedDisplay, by Ozhan Duran, covers. The sketch below uses it on the Arduino Uno: “Numbers on an eight-digit MAX7219 board”.

Ozhan Duran's DigitLedDisplay library, numbers on the MAX7219 eight-digit seven-segment board.

Each call is one sixteen-bit packet to one chip (no chains), shifted out on any three pins, as upstream does. As upstream, a minus sign shows as a 0, and nothing is lit until setDigitLimit() takes the chip out of shutdown.

The calls follow release 1.1.0 of the library, so a sketch written here builds on a real board too. The example is the one Mokxi's own tests build and run, so what is printed here is what runs.

Library Manager nameDigitLedDisplay
AuthorOzhan Duran
Include#include <DigitLedDisplay.h>
Boardsevery board Mokxi compiles for
In the simulatorSimulated: it runs against the part the way it does on the bench.
Parts it drivesEight-digit display, MAX7219

Install it

It builds on every board Mokxi compiles for.

In Mokxi it is built in: #include <DigitLedDisplay.h> and the sketch compiles, with no download, no zip and no Library Manager.

On a real board, install "DigitLedDisplay" by Ozhan Duran from the Arduino IDE’s Library Manager (Sketch, Include Library, Manage Libraries), or add DigitLedDisplay to lib_deps in PlatformIO. Mokxi follows the calls of release 1.1.0, so a sketch written here builds there too.

What to know in the simulator: One chip, no chains, as upstream. A minus sign shows as a 0, as upstream’s does.

The calls you will use

In the order a sketch meets them.

DigitLedDisplay ld

Makes ld, the DigitLedDisplay object the calls below are made on.

ld.setBright(10)

Sets the bright to the value you pass in. Arguments: brightness.

ld.setDigitLimit(8)

Sets the digit limit to the value you pass in. Arguments: limit.

ld.printDigit(12345678)

Prints the digit. Arguments: number, start digit.

ld.clear()

Clears it.

Example: Numbers on an eight-digit MAX7219 board

On the Arduino Uno R3. It runs in the browser exactly as printed.

sketch.ino · Arduino Uno R3
#include "DigitLedDisplay.h"

/* Board pin to display pin: DIN, CS, CLK */
DigitLedDisplay ld = DigitLedDisplay(2, 3, 4);

void setup() {
  Serial.begin(9600);

  /* Set the brightness min:1, max:15 */
  ld.setBright(10);

  /* Set the digit count */
  ld.setDigitLimit(8);

  ld.printDigit(12345678);
  delay(300);
  ld.clear();

  /* 1234 on the right, 56 starting from digit 4 */
  ld.printDigit(1234);
  ld.printDigit(56, 4);
  Serial.println("printed 56 1234");
}

void loop() {}

Wiring

  • Arduino Uno R3 2 to Eight-digit display, MAX7219 DIN
  • Arduino Uno R3 3 to Eight-digit display, MAX7219 CS
  • Arduino Uno R3 4 to Eight-digit display, MAX7219 CLK
  • Arduino Uno R3 5V to Eight-digit display, MAX7219 VCC
  • Arduino Uno R3 GND to Eight-digit display, MAX7219 GND

Open it in the editor, wired and ready to run

Try DigitLedDisplay without installing anything

Open the example, change the sketch, and keep your version in a free account.