#SENSOR ULTRASONIC
from machine import Pin
from hcsr04 import HCSR04
from time import sleep
medidor = HCSR04 (trigger_pin = 4, echo_pin = 5)
led = Pin (2, Pin.OUT)
while (True):
try:
distancia = medidor.distance_cm()
print("espacio = ", distancia)
if distancia >= 20:
led.value(1)
print("alerta")
else:
led.value(0)
print("No hay servicio")
sleep(1)
except:
print(error)