from machine import Pin, PWM
import time
import hcsr04
buzzer = Pin(4, Pin.OUT)
ultrasonic = hcsr04.HCSR04(trigger_pin = 13, echo_pin = 12, echo_timeout_us = 10000)
while True:
    distance = ultrasonic.distance_cm()
    if distance < 50:
        buzzer.on
    else:
        buzzer.off
    time.sleep(1)
    print('Distance:', distance, 'cm')