#Kevin Bermeo
#6/8/2025
from machine import Pin, I2C
import time
from lcd_api import LcdApi
from i2c_lcd import I2cLcd
# Configuración I2C para Raspberry Pi Pico (SDA=GP0, SCL=GP1)
i2c = I2C(0, scl=Pin(1), sda=Pin(0), freq=400000)
# Dirección del LCD I2C (prueba con 0x27 o 0x3F)
I2C_ADDR = 0x27
lcd = I2cLcd(i2c, I2C_ADDR, 2, 16)
# Botón en GP2
boton = Pin(2, Pin.IN, Pin.PULL_DOWN)
cont = 0
rebote = 0
debounce_ms = 200
lcd.clear()
lcd.putstr("Pulsame!!")
while True:
if boton.value() == 1 and time.ticks_ms() - rebote > debounce_ms:
cont += 1
rebote = time.ticks_ms()
# Mostrar en consola y LCD
lcd.clear()
lcd.putstr("Personas:\n{}".format(cont))
while boton.value() == 1:
pass # Esperar que se suelte
time.sleep(0.05)