from machine import Pin
from time import sleep
from picozero import DistanceSensor


ds = DistanceSensor(echo=17, trigger=16)



led = Pin(1, Pin.OUT)

while True:
    dist = ds.distance
    print(dist)
    if dist < 0.5:
        led.on()
    else:
        led.off()
    
    sleep(1)

BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT