from machine import Pin
import time
led1 = Pin(15, Pin.OUT)
led2 = Pin(16, Pin.OUT)
button1 = Pin(13, Pin.IN, Pin.PULL_UP)
button2 = Pin(14, Pin.IN, Pin.PULL_UP)
trang_thai_led1 = False
trang_thai_led2 = False
while True:
ttnutnhan1_hientai = button1.value()
if ttnutnhan1_hientai == 0:
trang_thai_led1 = not trang_thai_led1
led1.value(trang_thai_led1)
time.sleep(0.2) # chống dội phím
time.sleep(0.02)
ttnutnhan2_hientai = button2.value()
if ttnutnhan2_hientai == 0:
trang_thai_led2 = not trang_thai_led2
led2.value(trang_thai_led2)
time.sleep(0.2) # chống dội phím
time.sleep(0.02)