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)