from machine import Pin
from esp32_gpio_lcd import GpioLcd
from utime import sleep_ms, ticks_ms
lcd = GpioLcd(rs_pin=Pin(4),
enable_pin=Pin(17),
d4_pin=Pin(5),
d5_pin=Pin(18),
d6_pin=Pin(21),
d7_pin=Pin(22),
num_lines=2, num_columns=20)
button1 = Pin(34, Pin.IN, Pin.PULL_UP)
button2 = Pin(35, Pin.IN, Pin.PULL_UP)
value = 0
while True:
trangthai1 = button1.value()
trangthai2 = button2.value()
if trangthai1 == 1:
value = value + 1
sleep_ms(1000)
lcd.clear()
lcd.putstr(str(value))
if trangthai1 == 0 or trangthai2 == 0:
value = value
if trangthai2 == 1:
value = value - 1
sleep_ms(1000)
lcd.clear()
lcd.putstr(str(value))