from machine import Pin, I2C
from i2c_lcd import I2cLcd
import time
import random
sda=Pin(0)
scl=Pin(1)
red=Pin(2,Pin.OUT)
green=Pin(3,Pin.OUT)
blue=Pin(4,Pin.OUT)
yellow=Pin(6,Pin.OUT)
purple=Pin(7,Pin.OUT)
i2c=I2C(0,sda=sda,scl=scl, freq=400000)
devices=i2c.scan()
idcaddr=devices[0]
lcd=I2cLcd(i2c,idcaddr,2,16)
cnt=random.randint(1, 5)
lcd.putstr(str(cnt))
if(cnt==1):
red.toggle()
elif(cnt==2):
green.toggle()
elif(cnt==3):
blue.toggle()
elif(cnt==4):
yellow.toggle()
elif(cnt==5):
purple.toggle()