Index
Introduction
The MAX7219 8×8 LED Matrix module is a versatile component used to display text, numbers, and animations.
It simplifies the process of controlling individual LEDs in the 8×8 matrix using the MAX7219 chip.
This tutorial will guide you through connecting the matrix module to an ESP32 and programming it to display simple patterns, text, or scrolling messages.
Required Components
- ESP32 Board
- 8×8 LED Matrix Display Module
- Jumper wires
- Breadboard
Pinout

Circuit Diagram / Wiring
- VCC (LED Module) → 5V (ESP32)
- GND (LED Module) → GND (ESP32)
- DIN (LED Module) → Pin 32(ESP32)
- CS (LED Module) → Pin 5(ESP32)
- CLK (LED Module) → Pin 18(ESP32)

Code / Programming
#include <LedControl.h>
// ESP32 Pin Definitions (choose any available digital pins)
#define DATA_IN 23 // DIN
#define CLK 18 // CLK
#define CS 5 // LOAD/CS
// Create LedControl object: DIN, CLK, CS, number of devices
LedControl lc = LedControl(DATA_IN, CLK, CS, 1);
void setup() {
lc.shutdown(0, false); // Wake up display
lc.setIntensity(0, 8); // Set brightness (0–15)
lc.clearDisplay(0); // Clear display
}
void loop() {
displayNormalFace();
delay(1000);
lc.clearDisplay(0);
delay(500);
displayHeart();
delay(1000);
lc.clearDisplay(0);
delay(500);
displaySmileFace();
delay(1000);
lc.clearDisplay(0);
delay(500);
}
void displayNormalFace() {
byte normalFace[8] = {
B00111100,
B01000010,
B10100101,
B10000001,
B10000001,
B10111101,
B01000010,
B00111100
};
for (int row = 0; row < 8; row++) {
lc.setRow(0, row, normalFace[row]);
}
}
void displayHeart() {
byte heart[8] = {
B00000000,
B01100110,
B11111111,
B11111111,
B11111111,
B01111110,
B00111100,
B00011000
};
for (int row = 0; row < 8; row++) {
lc.setRow(0, row, heart[row]);
}
}
void displaySmileFace() {
byte smileFace[8] = {
B00111100,
B01000010,
B10100101,
B10000001,
B10100101,
B10011001,
B01000010,
B00111100
};
for (int row = 0; row < 8; row++) {
lc.setRow(0, row, smileFace[row]);
}
}
Explanation
- The MAX7219 chip controls an 8×8 LED matrix using just 3 GPIO pins from the ESP32 (DIN, CLK, CS).
- The ESP32 sends patterns or characters to the matrix through SPI-like serial communication using the
LedControl
library. - By defining custom byte arrays, you can display emojis, animations, or scrolling messages on the matrix.
Troubleshooting
- If nothing displays, double-check the wiring order (DIN, CLK, CS) and ensure VCC is 5V.
- Make sure the correct GPIO pins are used and match those in
LedControl
initialization. - If brightness is too low or LEDs flicker, increase brightness using
lc.setIntensity(0, level)
(0–15).