Arduino MAX7219 LED Matrix: Wiring, Code and Simulator
To build this Arduino MAX7219 LED Matrix project you need an Arduino Uno and a MAX7219 8x8 LED matrix. shiftOut sends register and data bytes to a MAX7219 that drives an 8x8 LED matrix. Make the 5 connections in the wiring table, upload the Arduino C++ code, and edit the SMILE rows: each byte is one row, bit 7 on the left.
Open this circuit in the free Arduino Uno simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | Arduino Uno | the microcontroller board |
| 1 | MAX7219 8x8 LED matrix | An 8×8 red matrix. Shift 16 bits (register, data) into DIN on CLK with CS LOW, then raise CS. Rows are registers 1–8; write 0x0C=1 to switch it on. |
Wiring
| # | From | To |
|---|---|---|
| 1 | Arduino Uno 5V | MAX7219 8x8 LED matrix VCC |
| 2 | Arduino Uno GND | MAX7219 8x8 LED matrix GND |
| 3 | Arduino Uno pin 11 | MAX7219 8x8 LED matrix DIN |
| 4 | Arduino Uno pin 10 | MAX7219 8x8 LED matrix CS |
| 5 | Arduino Uno pin 13 | MAX7219 8x8 LED matrix CLK |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the Arduino Uno. No install or account is needed.
- Add the parts. Add a MAX7219 8x8 LED matrix from the parts palette.
- Wire 1. Connect Arduino Uno 5V to MAX7219 8x8 LED matrix VCC.
- Wire 2. Connect Arduino Uno GND to MAX7219 8x8 LED matrix GND.
- Wire 3. Connect Arduino Uno pin 11 to MAX7219 8x8 LED matrix DIN.
- Wire 4. Connect Arduino Uno pin 10 to MAX7219 8x8 LED matrix CS.
- Wire 5. Connect Arduino Uno pin 13 to MAX7219 8x8 LED matrix CLK.
- Paste the Arduino C++ code. Paste the Arduino C++ code below into the code editor.
- Run it. Press Run. Edit the SMILE rows: each byte is one row, bit 7 on the left.
Arduino C++ code
// LED matrix: a MAX7219 drives 64 LEDs from three pins (DIN 11, CS 10, CLK 13).
// Every write is 16 bits: a register number, then its data.
const int DIN = 11, CS = 10, CLK = 13;
const byte SMILE[8] = {0x3C, 0x42, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C};
const byte FROWN[8] = {0x3C, 0x42, 0xA5, 0x81, 0x99, 0xA5, 0x42, 0x3C};
void send(byte reg, byte data) {
digitalWrite(CS, LOW);
shiftOut(DIN, CLK, MSBFIRST, reg);
shiftOut(DIN, CLK, MSBFIRST, data);
digitalWrite(CS, HIGH); // the rising edge latches the 16 bits
}
void show(const byte rows[8]) {
for (int r = 0; r < 8; r++) send(r + 1, rows[r]);
}
void setup() {
pinMode(DIN, OUTPUT);
pinMode(CS, OUTPUT);
pinMode(CLK, OUTPUT);
digitalWrite(CS, HIGH);
send(0x0F, 0); // display test off
send(0x0B, 7); // scan all 8 rows
send(0x09, 0); // no digit decoding: raw rows
send(0x0A, 8); // medium brightness
send(0x0C, 1); // wake up
}
void loop() {
show(SMILE);
delay(1000);
show(FROWN);
delay(1000);
}
What to try
Edit the SMILE rows: each byte is one row, bit 7 on the left.
Frequently asked questions
How do I wire the MAX7219 LED Matrix project on an Arduino Uno?
Make 5 connections: Arduino Uno 5V to MAX7219 8x8 LED matrix VCC; Arduino Uno GND to MAX7219 8x8 LED matrix GND; Arduino Uno pin 11 to MAX7219 8x8 LED matrix DIN; Arduino Uno pin 10 to MAX7219 8x8 LED matrix CS; Arduino Uno pin 13 to MAX7219 8x8 LED matrix CLK.
What parts do I need for this Arduino project?
An Arduino Uno and a MAX7219 8x8 LED matrix.
Can I simulate this Arduino project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and Arduino C++ code in your browser for free, with no install and no hardware. The sketch is compiled with the real Arduino toolchain and runs on an emulated ATmega328P.
What does the code do?
shiftOut sends register and data bytes to a MAX7219 that drives an 8x8 LED matrix.
More Arduino Uno projects
- Arduino LED Blink: Wiring, Code and Simulator
- Arduino LDR Light Sensor: Wiring, Code and Simulator
- Arduino NTC Thermistor Thermometer: Wiring, Code and Simulator
- Arduino PWM to Analog RC Filter: Wiring, Code and Simulator
- Arduino Capacitance Meter: Wiring, Code and Simulator
- Arduino DC Motor PWM Speed Control with MOSFET: Wiring, Code and Simulator