from machine import Pin, SPI
from max7219 import Max7219
from time import sleep_ms
# SPI setup
spi = SPI(1,
baudrate=10000000,
polarity=0,
phase=0,
sck=Pin(19),
mosi=Pin(23))
cs = Pin(18, Pin.OUT)
# 32x8 display (4 modules in a row)
display = Max7219(64, 8, spi, cs, rotate_180=True)
display.brightness(8)
def scroll_text_vertical(text):
display.fill(0)
length = 8 # height of one character (8 pixels)
# --- Scroll UP to DOWN ---
for pos in range(length + 8):
display.fill(0)
display.text(text, 0, pos - 8) # move text along Y-axis
display.show()
sleep_ms(150)
# --- Scroll DOWN to UP ---
for pos in range(length + 8):
display.fill(0)
display.text(text, 0, 8 - pos) # reverse direction
display.show()
sleep_ms(150)
while True:
scroll_text_vertical("PRIYAPANDI")