from machine import SPI, Pin, ADC
import time
import max7219
import machine

spi = SPI(1, baudrate=1000000, polarity=1, phase=0, sck=Pin(17, Pin.OUT), mosi=Pin(2, Pin.OUT))
ss = Pin(21, Pin.OUT)
pot = ADC(Pin(15, Pin.IN))
display = max7219.Matrix8x8(spi, ss, 1)
text = input("Enter text: ")
delay = (pot.read()/2**4)/1000


while True:
  delay = (pot.read()/2**4)/1000
  for x in range(0, len(text) * 8, 8):
    display.text(text, -x, 1, 1)
    display.show()
    delay = (pot.read()/2**2)/1000
    time.sleep(delay)
    display.text(text, -x, 1, 0)
  display.show()
  time.sleep(1 + delay)