from machine import Pin
from lcd import LCD
from time import sleep
# LCD
pantalla = LCD(19, 23, 18, 17, 16, 15)
# Botón
boton = Pin(21, Pin.IN, Pin.PULL_UP)
contador = 0
ultimo_estado = 1
def mostrar(numero):
pantalla.clear()
pantalla.move_to(0, 0)
pantalla.write("CONTADOR:")
pantalla.move_to(0, 1)
pantalla.write(str(numero))
while True:
estado = boton.value()
if estado == 0 and ultimo_estado == 1:
mostrar(contador)
contador += 1
if contador > 9:
contador = 0
sleep(0.3)
ultimo_estado = estado