from machine import Pin,SoftI2C
from machine import I2C
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
from time import sleep
I2C_ADDR=0X27
rows = 2
columns = 16
sdaPin=Pin(21)
sclPin=Pin(22)
button = Pin(19,Pin.IN,Pin.PULL_DOWN)
button1 = Pin(17,Pin.IN,Pin.PULL_DOWN)
i2c=I2C(0,sda=sdaPin, scl=sclPin,freq=1000)
lcd = I2cLcd(i2c,I2C_ADDR,rows,columns)
while True:
if button.value() == 1:
lcd.move_to(3,0)
lcd.putstr("RED")
sleep(1)
lcd.clear()
elif button1.value() == 1:
lcd.move_to(3,0)
lcd.putstr("YELLOW")
sleep(1)
lcd.clear()