from machine import Pin
motion_sensor = Pin(12, Pin.IN)
led = Pin(2, Pin.OUT)
led_status = False
while True:
motion_sensor_status = motion_sensor.value()
if motion_sensor_status == 1 and not led_status:
led.value(1)
led_status = True
elif motion_sensor_status == 0 and led_status:
led.value(0)
led_status = False