import max7219
from machine import Pin, SPI
import time
NUM_DEVICES = 4
CS_PIN = 4
spi = SPI(
2,
baudrate=10_000_000,
polarity=0,
phase=0,
sck=Pin(18),
mosi=Pin(23)
)
cs = Pin(CS_PIN, Pin.OUT)
display = max7219.Matrix8x8(spi, cs, NUM_DEVICES)
display.brightness(5)
DISPLAY_WIDTH = NUM_DEVICES * 8
def scroll_text(text, delay=0.06):
text_width = len(text) * 8
for x in range(DISPLAY_WIDTH, -text_width, -1):
display.fill(0)
display.text(text,x, 0, 1)
display.show()
time.sleep(delay)
while True:
scroll_text("HELLO")
time.sleep(1)