from machine import Pin
import time
# Define pins
pir_sensor = Pin(15, Pin.IN) # PIR sensor output
led = Pin(23, Pin.OUT) # LED output
print("PIR Motion Sensor Test (press Ctrl+C to stop)")
while True:
motion_detected = pir_sensor.value()
if motion_detected:
print("Motion detected!")
led.value(1) # Turn on LED
else:
print("No motion.")
led.value(0) # Turn off LED
time.sleep(0.5)