from machine import Pin, I2C
import time
from lcd_api import LcdApi
from pico_i2c_lcd import I2cLcd
# Configuración del LCD
I2C_ADDR = 0x27 # Dirección típica, cambia si es diferente
i2c = I2C(0, sda=Pin(0), scl=Pin(1), freq=400000)
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
# Configuración de botones
boton1 = Pin(2, Pin.IN, Pin.PULL_DOWN)
boton2 = Pin(3, Pin.IN, Pin.PULL_DOWN)
boton3 = Pin(4, Pin.IN, Pin.PULL_DOWN)
boton4 = Pin(5, Pin.IN, Pin.PULL_DOWN)
while True:
if boton1.value() == 1:
lcd.clear()
lcd.putstr("1")
time.sleep(0.3) # Debounce
elif boton2.value() == 1:
lcd.clear()
lcd.putstr("2")
time.sleep(0.3)
elif boton3.value() == 1:
lcd.clear()
lcd.putstr("3")
time.sleep(0.3)
elif boton4.value() == 1:
lcd.clear()
lcd.putstr("4")
time.sleep(0.3)