ELEGOO MEGA · LESSON 15
MAX7219 LED Dot Matrix Module
Display “Arduino” letter by letter, then run row, column and individual-LED patterns.
Send display commands to a single MAX7219 module.
Parts List
- ELEGOO Mega 2560 R3 is a 5 V ATmega2560 AVR board with many I/O pins and four hardware UARTs for control systems with several peripherals. Long ELEGOO-branded Mega PCB with USB-B and barrel connector, ATmega2560 marking, extended side headers and a large double-row digital header at the end. Read printed Mega labels; its SPI hardware placement is not the same numeric pins as an Uno.
- A USB-A to USB-B cable carries USB power and, when its data conductors are present, a host/device data link. USB-A plug and square USB-B plug. Inspect the plug shape; micro-USB is not USB-C, and USB-B is the squarer device connector.
- A MAX7219-driven 8×8 matrix displays monochrome patterns while driver ICs handle LED current setting and row multiplexing. Square dot matrix mounted over a driver PCB. Look for MAX7219 marking and DIN/CLK/LOAD connectors, not just an 8×8 luminous face.
- Male-to-female jumper leads make removable point-to-point connections for low-current prototype signals. Pin at one end and socket at the other. Check intact insulation and snug contacts before use.
Assembly
- Disconnect USB and use one MAX7219 module, not a bare matrix or the four-module panel.
- Connect to the DIN/input header; leave the DOUT/output header unused.
- Reconnect USB and observe a full pattern cycle.

Reviewed pin-to-pin connections
| From | To | Purpose / notes |
|---|---|---|
| Mega: 5V | MAX7219 input header: VCC | |
| Mega: GND | MAX7219 input header: GND | |
| Mega: D12 / DIN | MAX7219 input header: DIN | |
| Mega: D10 / CLK | MAX7219 input header: CLK | |
| Mega: D11 / CS | MAX7219 input header: CS / LOAD |
Code
Download complete PlatformIO project
ZIP includes platformio.ini, src/main.cpp, and bundled libraries (LedControl).
Extract the ZIP, then open its workspaces/lesson-15 folder in VS Code. Keep the adjacent third-party folder in place.
PlatformIO configuration
[env:mega]
platform = atmelavr@5.3.0
board = megaatmega2560
framework = arduino
monitor_speed = 9600
lib_deps =
file://../../third-party/LedControl
#include <Arduino.h>
// LedControl.h provides convenient functions for a MAX7219 LED matrix.
#include <LedControl.h>
// LedControl constructor order is DIN, CLK, CS, number of devices.
// Create one matrix object: data pin 12, clock pin 10, chip-select pin 11, one device.
LedControl matrix(12, 10, 11, 1);
// A two-dimensional array stores seven letter patterns, each made from five byte columns.
const byte LETTERS[7][5] = {
{0x7E, 0x88, 0x88, 0x88, 0x7E}, // a
{0x10, 0x20, 0x20, 0x10, 0x3E}, // r
{0xFE, 0x12, 0x22, 0x12, 0x0E}, // d
{0x3E, 0x04, 0x02, 0x04, 0x3E}, // u
{0x00, 0x02, 0xBE, 0x22, 0x00}, // i
{0x1E, 0x20, 0x20, 0x10, 0x1E}, // n
{0x1C, 0x22, 0x22, 0x22, 0x1C} // o
};
// Wake the matrix, set brightness, and clear any old pixels.
void setup() {
// Device index 0: false means do not leave it in shutdown mode.
matrix.shutdown(0, false);
// Set the brightness level (0–15) to a middle value.
matrix.setIntensity(0, 8);
matrix.clearDisplay(0);
}
// First show letters, then run several LED pattern animations.
void loop() {
// Walk through each of the seven entries in the LETTERS array.
for (uint8_t letter = 0; letter < 7; ++letter) {
matrix.clearDisplay(0);
// Set five matrix rows from the selected stored pattern.
for (uint8_t row = 0; row < 5; ++row) matrix.setRow(0, row, LETTERS[letter][row]);
delay(500);
}
matrix.clearDisplay(0);
delay(500);
// Make a row-by-row flashing pattern using nested loops.
for (uint8_t row = 0; row < 8; ++row) {
for (uint8_t blink = 0; blink <= row; ++blink) {
delay(50);
// 0xA0 is a hexadecimal bit pattern; each set bit lights a pixel.
matrix.setRow(0, row, 0xA0);
delay(50);
matrix.setRow(0, row, 0);
}
}
// Repeat the pattern a column at a time.
for (uint8_t col = 0; col < 8; ++col) {
for (uint8_t blink = 0; blink <= col; ++blink) {
delay(50);
matrix.setColumn(0, col, 0xA0);
delay(50);
matrix.setColumn(0, col, 0);
}
}
// Finally visit each LED coordinate and blink it as the animation fills.
for (uint8_t row = 0; row < 8; ++row) {
for (uint8_t col = 0; col < 8; ++col) {
delay(50);
matrix.setLed(0, row, col, true);
delay(50);
for (uint8_t blink = 0; blink < col; ++blink) {
matrix.setLed(0, row, col, false);
delay(50);
// Set one LED at the current row/column position to ON.
matrix.setLed(0, row, col, true);
delay(50);
}
}
}
}
Expected behavior
The module displays the seven Arduino glyphs one at a time, followed by row, column and individual-pixel patterns; this is not a scrolling-text sketch.
Experiments & Challenges
- Reduce setIntensity(0,8) to a lower value.
- Change one five-row glyph in LETTERS.
Troubleshooting
- Blank/random output: check DIN12, CLK10 and CS11; LedControl’s constructor order is DIN, CLK, CS, not DIN, CS, CLK.