from machine import Pin, I2C
from utime import sleep
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
# Configuración del bus I2C (usa tus pines SDA=26, SCL=27)
i2c = I2C(1, sda=Pin(26), scl=Pin(27), freq=400000)
I2C_ADDR = 0x27 # Dirección común del LCD I2C
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
# Pines de salida para LEDs
red = Pin(2, Pin.OUT)
green = Pin(6, Pin.OUT)
yellow = Pin(3, Pin.OUT)
# Botones de entrada
btn_green = Pin(10, Pin.IN, Pin.PULL_DOWN)
btn_red = Pin(11, Pin.IN, Pin.PULL_DOWN)
btn_yellow = Pin(9, Pin.IN, Pin.PULL_DOWN)
lcd.putstr("Listo!\nEsperando...")
while True:
if btn_green.value():
lcd.clear()
lcd.putstr("VERDE ON")
green.value(1)
sleep(1)
green.value(0)
lcd.clear()
lcd.putstr("Esperando...")
if btn_yellow.value():
lcd.clear()
lcd.putstr("AMARILLO ON")
yellow.value(1)
sleep(1)
yellow.value(0)
lcd.clear()
lcd.putstr("Esperando...")
if btn_red.value():
lcd.clear()
lcd.putstr("ROJO ON")
red.value(1)
sleep(1)
red.value(0)
lcd.clear()
lcd.putstr("Esperando...")