from machine import Pin from time import sleep ir = Pin(15, Pin.IN) while True: sensor_state = ir.value() print(sensor_state) sleep(1) if ir.value() == 0:break