from machine import Pin
from time import sleep
pir = Pin(8, Pin.IN)
led = Pin(28, Pin.OUT)
# Continuously read data from the PIR sensor
while True:
if pir.value() == 1:
print("PIR value:", pir.value(), "Status: Motion detected!")
led.on()
sleep(5)
led.off()
else:
print("PIR value:", pir.value(), "Status: Waiting for movement...")
sleep(1) # PIR sensor checks for movement every second