from machine import Pin
from time import sleep

ir=Pin(14,Pin.IN)
led=Pin(19,Pin.OUT)
led_state=0
ir_value=0

while True:
    try:
        last_state = ir_value
        ir_value = ir.value()
        if  ir_value==1 and last_state==0:
            led_state = not(led_state)
            led.value(led_state)
        sleep(0.001)

    except KeyboardInterrupt:
        break
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT