Built-in project · Arduino Uno R3

MAX7219 scrolling text display on an Arduino Uno

A 4-in-1 MAX7219 LED matrix scrolls a message right to left with MD_Parola. Type a new one in the serial monitor and it takes over on the next pass. The whole build, an Arduino Uno and 1 more part, runs here in your browser on the firmware below; open it in the editor to change the wiring or the code and run it again.

Teaching? Assign it to your class in one click.

Beginner Runs in your browser. Free, and no account needed.

The parts retail for about $30. On Mokxi they're free.

MAX7219 scrolling text display · Arduino Uno R3live0.000 s 0.00x
Click to open it in the editor
The circuit itself, running here on the simulator. Press what can be pressed; click anything else to open it in the editor.

The note on the canvas

Word for word, as it sits beside the circuit in the editor.

Try it
1. Press Run. "Hello from Mokxi!" scrolls in from the right.
2. Open the serial monitor, type a message and press Enter.
3. When the old message has scrolled off, yours takes over.
4. In the code, change SCROLL_MS to speed it up or slow it down.

The code

The firmware exactly as the editor opens it. Change a line there and press Run: it compiles in the browser.

sketch.ino · Arduino Uno R3
// MAX7219 scrolling text: a 4-in-1 dot matrix module (four 8x8 matrices,
// 32 by 8 LEDs) scrolls a message right to left with MD_Parola, the library
// most scrolling signs use. Type a new message in the serial monitor and
// press Enter, and it takes over at the start of the next pass.
//
//   MAX7219 module   VCC 5V, GND GND
//                    DIN pin 11 (MOSI), CLK pin 13 (SCK), CS pin 10
//
// MD_Parola sits on top of MD_MAX72xx, which talks to the four MAX7219 chips
// over SPI. displayText() sets the message up once; displayAnimate() never
// waits, it moves the text one column each time SCROLL_MS has passed, so
// loop() stays free to read the serial monitor in between. When a pass ends,
// displayAnimate() returns true and displayReset() starts the next one.
//
// HARDWARE_TYPE says how the matrices on a real board are wired to their
// chips. The blue 4-in-1 boards sold for scrolling text are FC16_HW; if your
// text comes out mirrored or upside down, try PAROLA_HW or GENERIC_HW.
//
// Things to change: MAX_DEVICES for a longer chain (8 for two boards end to
// end), SCROLL_MS for the speed (smaller is faster), and setIntensity() for
// the brightness, 0 to 15. A real module on full brightness can pull close
// to an amp, so keep it low on USB power.

#include <MD_Parola.h>
#include <MD_MAX72xx.h>
#include <SPI.h>

#define HARDWARE_TYPE MD_MAX72XX::FC16_HW
#define MAX_DEVICES 4
#define CS_PIN 10

const uint16_t SCROLL_MS = 40;  // time per column, in milliseconds
const int MAX_TEXT = 64;

MD_Parola display(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

char message[MAX_TEXT + 1] = "Hello from Mokxi!";
char typed[MAX_TEXT + 1];
int typedLength = 0;
bool waiting = false;  // a new message is ready for the next pass

void setup() {
  Serial.begin(9600);
  display.begin();
  display.setIntensity(2);
  display.displayClear();
  display.displayText(message, PA_LEFT, SCROLL_MS, 0, PA_SCROLL_LEFT, PA_SCROLL_LEFT);
  Serial.print("Scrolling: ");
  Serial.println(message);
  Serial.println("Type a new message and press Enter.");
}

void loop() {
  // Collect what is typed, one character at a time, until Enter.
  while (Serial.available()) {
    char c = Serial.read();
    if (c == '\n') {
      if (typedLength > 0) {
        typed[typedLength] = '\0';
        waiting = true;
        Serial.print("Next pass: ");
        Serial.println(typed);
      }
      typedLength = 0;
    } else if (c >= ' ' && typedLength < MAX_TEXT) {
      // Printable characters only: a carriage return, a tab or any other
      // control character has no shape in the font.
      typed[typedLength++] = c;
    }
  }

  // The end of a pass: start the next one, with the new message if there is one.
  if (display.displayAnimate()) {
    if (waiting) {
      strcpy(message, typed);
      waiting = false;
      Serial.print("Scrolling: ");
      Serial.println(message);
    }
    display.displayReset();
  }
}

Parts list

3 parts, plus the jumper wires. They retail for about $30; on Mokxi they're free.

How it is wired

6 connections, pin by pin, read from the circuit itself. Each line is one set of pins joined together, by a jumper wire or a breadboard strip.

  • Ground: Arduino Uno R3 pin GND
  • Arduino Uno R3 pin 13; LED matrix, 8x8 pin CLK
  • Arduino Uno R3 pin 11; LED matrix, 8x8 pin DIN
  • Arduino Uno R3 pin 10; LED matrix, 8x8 pin CS
  • 5 V: LED matrix, 8x8 pin VCC
  • Ground: LED matrix, 8x8 pin GND

Questions and answers

Which libraries does this use?

MD_Parola, which runs on top of MD_MAX72xx, plus SPI. Both are in the Arduino Library Manager under those names.

My text is mirrored or upside down on a real module. What do I change?

Change HARDWARE_TYPE. The blue 4-in-1 boards are usually FC16_HW; if the text looks wrong, try PAROLA_HW or GENERIC_HW.

How do I make it scroll faster or slower?

Change SCROLL_MS, the time per column in milliseconds. Smaller is faster.

Can I chain more modules?

Yes. Set MAX_DEVICES to the number of 8x8 blocks, for example 8 for two 4-in-1 boards end to end, and connect DOUT of one to DIN of the next.

Change it and keep it

Open it in the editor, change the circuit or the code, and keep your version in a free account.