from hcsr04 import HCSR04
import time
TRIGGER_PIN = 5
ECHO_PIN = 18
sensor = HCSR04(TRIGGER_PIN, ECHO_PIN)
while True:
try:
distance = sensor.get_distance_cm()
print(f"Distance: {distance} cm")
except OSError as e:
print(e)
time.sleep(1)