from machine import Pin
import time
# Define PIR sensor input and LED output
pir = Pin(12, Pin.IN) # Adjust the GPIO pin as needed
led = Pin(27, Pin.OUT) # Built-in LED or external LED
while True:
if pir.value() == 1: # Motion detected
led.value(1)
print("Motion detected!")
else:
led.value(0)
print("Motion is not detected!")
time.sleep(0.1) # Small delay to avoid excessive processing