import time
import utime
import random
from machine import I2C,SoftI2C,Pin,Timer,RTC,ADC
from pico_i2c_lcd import I2cLcd
i2c = SoftI2C(sda=Pin(26),scl= Pin(21), freq = 400000)
addr =""
devices = i2c.scan()
if devices:
for device in devices:
addr = device
print(hex(addr))
lcd = I2cLcd(i2c,addr,2,16)
ledR = Pin(1,Pin.OUT)
ledY = Pin(5,Pin.OUT)
ledG = Pin(9,Pin.OUT)
rtc = RTC()
rtc.datetime((2024,2,6,3,11,46,0,0))
# times = rtc.datetime()
t = 5
lcd.clear()
while True:
num = random.random()
if num>0.75:
while t>0:
ledR.on()
lcd.move_to(1,16)
lcd.putstr(str(rtc.datetime()))
time.sleep(2)
lcd.clear()
t=t-1
ledR.off()
t=5
if num<=0.75 and num>=0.5:
ledG.on()
lcd.move_to(2,16)
lcd.putstr(str(rtc.datetime()))
time.sleep(2)
lcd.clear()
t=t-1
ledG.off()
t=5
if num<0.5:
ledY.on()
lcd.move_to(2,16)
lcd.putstr(str(rtc.datetime()))
time.sleep(2)
lcd.clear()
t=t-1
ledY.off()