ESP32-C3 SPI MAX7219 LED Matrix: Wiring, Code and Simulator
To build this ESP32-C3 SPI MAX7219 LED Matrix project you need an ESP32-C3 DevKitM-1 and a MAX7219 8x8 LED matrix. Hardware SPI on the ESP32-C3 native pins (IO6 SCK, IO7 MOSI, IO10 CS) animates faces on a MAX7219 8x8 matrix. Make the 5 connections in the wiring table, upload the MicroPython code, and open the logic analyzer on IO6, IO7 and IO10 to see each two-byte SPI write, or draw your own 8x8 face.
Open this circuit in the free ESP32-C3 DevKitM-1 simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | ESP32-C3 DevKitM-1 | 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 | ESP32-C3 DevKitM-1 IO7 | MAX7219 8x8 LED matrix DIN |
| 2 | ESP32-C3 DevKitM-1 IO6 | MAX7219 8x8 LED matrix CLK |
| 3 | ESP32-C3 DevKitM-1 IO10 | MAX7219 8x8 LED matrix CS |
| 4 | ESP32-C3 DevKitM-1 5V | MAX7219 8x8 LED matrix VCC |
| 5 | ESP32-C3 DevKitM-1 GND | MAX7219 8x8 LED matrix GND |
Step by step
- Open the simulator. Open the BitForBytes Embedded Lab in your browser and start from the ESP32-C3 DevKitM-1. No install or account is needed.
- Add the parts. Add a MAX7219 8x8 LED matrix from the parts palette.
- Wire 1. Connect ESP32-C3 DevKitM-1 IO7 to MAX7219 8x8 LED matrix DIN.
- Wire 2. Connect ESP32-C3 DevKitM-1 IO6 to MAX7219 8x8 LED matrix CLK.
- Wire 3. Connect ESP32-C3 DevKitM-1 IO10 to MAX7219 8x8 LED matrix CS.
- Wire 4. Connect ESP32-C3 DevKitM-1 5V to MAX7219 8x8 LED matrix VCC.
- Wire 5. Connect ESP32-C3 DevKitM-1 GND to MAX7219 8x8 LED matrix GND.
- Paste the MicroPython code. Paste the MicroPython code below into the code editor.
- Run it. Press Run. Open the logic analyzer on IO6, IO7 and IO10 to see each two-byte SPI write, or draw your own 8x8 face.
MicroPython code
# ESP32-C3 (real chip emulation): an 8x8 LED matrix (MAX7219) over hardware SPI.
# SPI2 on its native pins: SCK = IO6, MOSI = IO7; chip select on IO10.
# Each register write is two bytes: the register (1-8 = a row), then its bits.
from machine import Pin, SPI
import time
spi = SPI(1, baudrate=2_000_000, polarity=0, phase=0, sck=Pin(6), mosi=Pin(7))
cs = Pin(10, Pin.OUT, value=1)
def reg(r, v):
cs(0)
spi.write(bytes([r, v]))
cs(1)
for r, v in ((0x0F, 0), (0x0C, 1), (0x0B, 7), (0x09, 0), (0x0A, 4)):
reg(r, v) # test off, wake up, scan all rows, no decode, brightness
SMILE = (0x3C, 0x42, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C)
WINK = (0x3C, 0x42, 0x85, 0x81, 0xA5, 0x99, 0x42, 0x3C)
HEART = (0x00, 0x66, 0xFF, 0xFF, 0xFF, 0x7E, 0x3C, 0x18)
frame = 0
while True:
for face in (SMILE, WINK, SMILE, HEART):
for row, bits in enumerate(face):
reg(row + 1, bits)
frame += 1
print("frame", frame)
time.sleep_ms(500)
What to try
Open the logic analyzer on IO6, IO7 and IO10 to see each two-byte SPI write, or draw your own 8x8 face.
Frequently asked questions
How do I wire the SPI MAX7219 LED Matrix project on an ESP32-C3 DevKitM-1?
Make 5 connections: ESP32-C3 DevKitM-1 IO7 to MAX7219 8x8 LED matrix DIN; ESP32-C3 DevKitM-1 IO6 to MAX7219 8x8 LED matrix CLK; ESP32-C3 DevKitM-1 IO10 to MAX7219 8x8 LED matrix CS; ESP32-C3 DevKitM-1 5V to MAX7219 8x8 LED matrix VCC; ESP32-C3 DevKitM-1 GND to MAX7219 8x8 LED matrix GND.
What parts do I need for this ESP32-C3 project?
An ESP32-C3 DevKitM-1 and a MAX7219 8x8 LED matrix.
Can I simulate this ESP32-C3 project online for free?
Yes. The BitForBytes Embedded Lab runs this exact circuit and MicroPython code in your browser for free, with no install and no hardware. The ESP32-C3 is emulated instruction by instruction on a RISC-V core running the official MicroPython firmware.
What does the code do?
Hardware SPI on the ESP32-C3 native pins (IO6 SCK, IO7 MOSI, IO10 CS) animates faces on a MAX7219 8x8 matrix.
More ESP32-C3 DevKitM-1 projects
- ESP32-C3 Button Interrupt + Blink: Wiring, Code and Simulator
- ESP32-C3 ADC Potentiometer Meter: Wiring, Code and Simulator
- ESP32-C3 PWM, NeoPixel & I2C LCD: Wiring, Code and Simulator
- ESP32-C3 Wi-Fi Weather on an LCD: Wiring, Code and Simulator
- ESP32-C3 Bluetooth LE Sensor: Wiring, Code and Simulator