Breadboard
docs
Example project · Displays & sensors

LED matrix beating heart (MAX7219)

An 8×8 LED matrix driven by a MAX7219 over SoftSPI, pulsing a heart. The SPI words are decoded with cycle accuracy: registers 1–8 = the eight rows.

The LED matrix beating heart (MAX7219) circuit as rendered by the simulator

What's on the bench

  • Battery
  • ESP32-C3
  • LED Matrix 8×8

The code

This MicroPython script runs on the emulated board every boot; edit it in the Code tab.

from machine import Pin, SoftSPI
import time
spi = SoftSPI(baudrate=1000000, sck=Pin(6), mosi=Pin(4), miso=Pin(5))
cs = Pin(3, Pin.OUT, value=1)
def reg(a, d):
    cs(0); spi.write(bytes([a, d])); cs(1)
for a, d in ((0x0f, 0), (0x0b, 7), (0x09, 0), (0x0a, 3), (0x0c, 1)):
    reg(a, d)
heart = [0x00, 0x66, 0xff, 0xff, 0xff, 0x7e, 0x3c, 0x18]
def draw(rows):
    for k in range(8):
        reg(k + 1, rows[k])
on = True
while True:
    draw(heart if on else [0] * 8)
    print('beat', on)
    on = not on
    time.sleep_ms(500)