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

QtyPartWhat it does
1ESP32-C6 DevKitC-1the microcontroller board
1MAX7219 8x8 LED matrixAn 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

#FromTo
1ESP32-C6 DevKitC-1 IO7MAX7219 8x8 LED matrix DIN
2ESP32-C6 DevKitC-1 IO6MAX7219 8x8 LED matrix CLK
3ESP32-C6 DevKitC-1 IO10MAX7219 8x8 LED matrix CS
4ESP32-C6 DevKitC-1 5VMAX7219 8x8 LED matrix VCC
5ESP32-C6 DevKitC-1 GNDMAX7219 8x8 LED matrix GND

Step by step

  1. 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.
  2. Add the parts. Add a MAX7219 8x8 LED matrix from the parts palette.
  3. Wire 1. Connect ESP32-C6 DevKitC-1 IO7 to MAX7219 8x8 LED matrix DIN.
  4. Wire 2. Connect ESP32-C6 DevKitC-1 IO6 to MAX7219 8x8 LED matrix CLK.
  5. Wire 3. Connect ESP32-C6 DevKitC-1 IO10 to MAX7219 8x8 LED matrix CS.
  6. Wire 4. Connect ESP32-C6 DevKitC-1 5V to MAX7219 8x8 LED matrix VCC.
  7. Wire 5. Connect ESP32-C6 DevKitC-1 GND to MAX7219 8x8 LED matrix GND.
  8. Paste the MicroPython code. Paste the MicroPython code below into the code editor.
  9. 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