from utime import sleep
sleep(0.1) # Wait for USB to become ready
import random
from machine import Pin, I2C, Timer
from pico_i2c_lcd import I2cLcd
sda = Pin(0)
scl = Pin(1)
i2c = I2C(0, sda=sda, scl=scl, freq=40000)
devices = i2c.scan()
i2c_addr = devices[0]
lcd = I2cLcd(i2c, i2c_addr, 2, 16)
leds = []
for i in range(16, 21):
leds.append(Pin(i, Pin.OUT))
def random_num(t):
num = random.randint(1, 5)
lcd.putstr(str(num))
leds[num - 1].on()
sleep(0.5)
leds[num - 1].off()
lcd.clear()
tim = Timer(mode=Timer.PERIODIC, freq=1, callback=random_num)