# LED Matrix with Arduino: Wiring, Calculations, and Scrolling Text

An LED matrix is a grid of tiny lights that can display letters, numbers, and simple icons. A common beginner module contains an 8 × 8 matrix and a MAX7219 driver, which handles the LEDs so your microcontroller does not need one pin per LED.

This guide shows how to connect one or more modules and scroll a message using Arduino. The same approach works with many ESP32 boards.

—

## What You Need

Hardware:

  • Arduino Uno/Nano or an ESP32 development board
  • MAX7219 8 × 8 matrix module (or several modules joined together)
  • Jumper wires
  • USB cable and a computer

Software:

  • Arduino IDE
  • MD_Parola and MD_MAX72XX libraries (install both from the Arduino IDE Library Manager)

MD_Parola provides text and animation functions; MD_MAX72XX controls the MAX7219 hardware. The module’s matrix layout varies, so the HARDWARE_TYPE setting may need adjustment. MD_Parola library

—

## How the Matrix Works

An 8 × 8 matrix has 8 rows × 8 columns = 64 LEDs. The MAX7219 scans the rows quickly and stores the display data, so the Arduino sends updates instead of controlling all 64 LEDs individually.

Modules are commonly daisy-chained. Each module adds 8 columns:

Display width in pixels = number of modules × 8

For example, four modules make a 32 × 8 pixel display. More modules give scrolling text more room, but the display still has only 8 pixels of height.

—

## Wiring

Connect the module’s input side (often marked IN) to the controller:

MAX7219 moduleArduino Uno/NanoESP32 example
VCC5V5V / VIN*
GNDGNDGND
DIND11GPIO 23
CS or LOADD10GPIO 5
CLKD13GPIO 18

*Use the board’s 5V/VIN pin only if its documentation allows it. MAX7219 modules are usually powered from 5 V; do not assume an ESP32 3.3 V output can power the matrix. Keep grounds connected together. For SPI-capable boards, the data and clock pins can often use hardware SPI pins, but this example uses the library’s pin-based interface.

For multiple modules, connect the controller to IN on the first module, then connect its OUT to the next module’s IN. Follow the labels printed on your particular board.

—

## Install and Configure the Libraries

In Arduino IDE, open Sketch → Include Library → Manage Libraries, search for and install MD_Parola and MD_MAX72XX. Then select your board and port.

The example below uses the common FC-16 style module. If the display is scrambled, mirrored, or upside down, try another HARDWARE_TYPE supported by MD_MAX72XX, such as GENERIC_HW or PAROLA_HW.

—

## Simple Scrolling Text Example

Set MAX_DEVICES to the number of modules connected in a chain. The following sketch scrolls “Hello, world!” from right to left, waits briefly, then starts again.

#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

MD_Parola display(HARDWARE_TYPE, CS_PIN, MAX_DEVICES);

const uint16_t SCROLL_SPEED = 50;  // Smaller number = faster
const uint16_t PAUSE_TIME = 1000;  // Pause at the end, in milliseconds

void setup() {
  display.begin();
  display.setIntensity(2);  // Brightness: 0 (dim) to 15 (bright)
  display.displayClear();

  display.displayText(
    "Hello, world!",
    PA_LEFT,
    SCROLL_SPEED,
    PAUSE_TIME,
    PA_SCROLL_LEFT,
    PA_SCROLL_LEFT
  );
}

void loop() {
  // Keep calling this: it advances the animation without blocking.
  if (display.displayAnimate()) {
    display.displayReset();  // Restart the same message
  }
}

Upload the sketch. If the text does not appear in the right direction, check that the controller is connected to the first module’s IN connector and try a different hardware type.

—

## Key Functions

  • display.begin() initializes the display.
  • display.setIntensity(0..15) sets brightness. Start low and increase only as needed.
  • display.displayClear() clears the current display contents.
  • display.displayText(...) sets text, alignment, speed, pause, and entry/exit effects.
  • display.displayAnimate() advances the animation. Call it repeatedly from loop().
  • display.displayReset() restarts the current animation after it completes.

For a short, static message, use a print effect instead of scrolling:

display.displayText("READY", PA_CENTER, 0, 0, PA_PRINT, PA_NO_EFFECT);

Continue calling display.displayAnimate() in loop() for the library to draw the text. A short word fits only if it fits within the available columns; otherwise use a scrolling effect.

—

## Practical Notes

  • Set the module count correctly. MAX_DEVICES must match the number of chained modules.
  • Check the module type. A wrong hardware setting often causes rotated, mirrored, or scrambled characters.
  • Use a suitable power source. The matrix can draw substantially more current when many LEDs are lit. For several modules or high brightness, use a regulated 5 V supply sized for the modules and join its ground to the controller ground. Do not power a large display from a microcontroller’s 3.3 V pin.
  • Limit brightness. Brightness affects power use and glare; a low setting is usually readable indoors.
  • Avoid long delays in loop(). They make animation choppy. Keep calling displayAnimate() so scrolling stays smooth.
  • Mind the font. Small 8 × 8 matrices work best with short, simple text. Accented characters and non-Latin scripts may need a custom font.
  • For ESP32, change CS_PIN to a suitable GPIO and check the board’s SPI pinout. Keep GPIO choices compatible with your specific board.

—

## Quick Calculation Example

Suppose you want a 40-pixel-wide display from 8 × 8 modules:

Modules needed = desired width / 8
               = 40 / 8
               = 5 modules

If the desired width is not a multiple of 8, round up. For a 36-pixel target, use ceil(36 / 8) = 5 modules, giving 40 columns. In practice, choose enough modules for the text and leave a little blank space at each end.

The MAX7219 handles multiplexing and current regulation for its LEDs, but it does not make every module or power supply combination safe. Follow the module’s voltage guidance and choose a supply with enough current for your chain.

—

## Conclusion

A MAX7219 matrix is a simple way to add readable text to an Arduino or ESP32 project. Connect the five module signals, install MD_Parola and MD_MAX72XX, set the correct hardware type and module count, then use displayText() with displayAnimate() to create scrolling text.

Start with one module and low brightness. Once it works, chain more modules and adjust the message, speed, and effects.

—

## Further Reading

—

Have you built a scrolling LED matrix display? Share what you displayed and which module you used in the comments.