ESP32-C6 SPI MAX7219 LED Matrix: Wiring, Code and Simulator
To build this ESP32-C6 SPI MAX7219 LED Matrix project you need an ESP32-C6 DevKitC-1 and a MAX7219 8x8 LED matrix. Hardware SPI (with DMA) on IO6 SCK, IO7 MOSI and 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 face.
Open this circuit in the free ESP32-C6 DevKitC-1 simulator
Parts list
| Qty | Part | What it does |
|---|---|---|
| 1 | ESP32-C6 DevKitC-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-C6 DevKitC-1 IO7 | MAX7219 8x8 LED matrix DIN |
| 2 | ESP32-C6 DevKitC-1 IO6 | MAX7219 8x8 LED matrix CLK |
| 3 | ESP32-C6 DevKitC-1 IO10 | MAX7219 8x8 LED matrix CS |
| 4 | ESP32-C6 DevKitC-1 5V | MAX7219 8x8 LED matrix VCC |
| 5 | ESP32-C6 DevKitC-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-C6 DevKitC-1. No install or account is needed.
- Add the parts. Add a MAX7219 8x8 LED matrix from the parts palette.
- Wire 1. Connect ESP32-C6 DevKitC-1 IO7 to MAX7219 8x8 LED matrix DIN.
- Wire 2. Connect ESP32-C6 DevKitC-1 IO6 to MAX7219 8x8 LED matrix CLK.
- Wire 3. Connect ESP32-C6 DevKitC-1 IO10 to MAX7219 8x8 LED matrix CS.
- Wire 4. Connect ESP32-C6 DevKitC-1 5V to MAX7219 8x8 LED matrix VCC.
- Wire 5. Connect ESP32-C6 DevKitC-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 face.
MicroPython code
# ESP32-C6: an 8x8 LED matrix over hardware SPI.
# SPI2 on IO6 (SCK), IO7 (MOSI) and IO10 (CS) drives a MAX7219, two bytes per
# register: animated faces.
from machine import Pin, SPI
import time
spi = SPI(1, baudrate=1_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 ((0x0C, 1), (0x09, 0), (0x0B, 7), (0x0A, 4), (0x0F, 0)):
reg(r, v)
SMILE = (0x3C, 0x42, 0xA5, 0x81, 0xA5, 0x99, 0x42, 0x3C)
WINK = (0x3C, 0x42, 0xA1, 0x81, 0xA5, 0x99, 0x42, 0x3C)
while True:
for face in (SMILE, WINK):
for row, bits in enumerate(face):
reg(row + 1, bits)
time.sleep_ms(600)
What to try
Open the logic analyzer on IO6, IO7 and IO10 to see each two-byte SPI write, or draw your own face.
Frequently asked questions
How do I wire the SPI MAX7219 LED Matrix project on an ESP32-C6 DevKitC-1?
Make 5 connections: ESP32-C6 DevKitC-1 IO7 to MAX7219 8x8 LED matrix DIN; ESP32-C6 DevKitC-1 IO6 to MAX7219 8x8 LED matrix CLK; ESP32-C6 DevKitC-1 IO10 to MAX7219 8x8 LED matrix CS; ESP32-C6 DevKitC-1 5V to MAX7219 8x8 LED matrix VCC; ESP32-C6 DevKitC-1 GND to MAX7219 8x8 LED matrix GND.
What parts do I need for this ESP32-C6 project?
An ESP32-C6 DevKitC-1 and a MAX7219 8x8 LED matrix.
Can I simulate this ESP32-C6 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-C6 is emulated instruction by instruction on its RISC-V core, running its own ROM and the official MicroPython firmware.
What does the code do?
Hardware SPI (with DMA) on IO6 SCK, IO7 MOSI and IO10 CS animates faces on a MAX7219 8x8 matrix.
More ESP32-C6 DevKitC-1 projects
- ESP32-C6 RGB LED, Blink and Button Interrupt: Wiring, Code and Simulator
- ESP32-C6 ADC Knob Dims an LED (PWM): Wiring, Code and Simulator
- ESP32-C6 I2C LCD: Wiring, Code and Simulator
- ESP32-C6 Wi-Fi Weather on an LCD: Wiring, Code and Simulator
- ESP32-C6 nRF24L01 Receiver: Wiring, Code and Simulator
- ESP32-C6 HC-05 Bluetooth LED Control: Wiring, Code and Simulator