from machine import Pin
import time
# PIR đọc tín hiệu chuyển động
pir = Pin(16, Pin.IN)
# LED báo trạng thái
led = Pin(15, Pin.OUT)
while True:
# Có chuyển động thì PIR lên mức 1 và LED sáng
if pir.value() == 1:
led.value(1)
else:
led.value(0)
time.sleep_ms(50)