from machine import Pin
import time
led = Pin(15, Pin.OUT)
button = Pin(14, Pin.IN, Pin.PULL_UP)
trang_thai_led = False
ttnutnhan_cuoi = 1
while True:
ttnutnhan_hientai = button.value()
if ttnutnhan_cuoi == 1 and ttnutnhan_hientai == 0:
trang_thai_led = not trang_thai_led
led.value(trang_thai_led)
time.sleep(0.2) # chống dội phím
ttnutnhan_cuoi = ttnutnhan_hientai
time.sleep(0.02)