from machine import Pin, ADC, PWM
from time import sleep
from hcsr04 import HCSR04
ultrasonic = HCSR04(trigger_pin=13, echo_pin=12, echo_timeout_us=1000000)
led1 = Pin(2, Pin.OUT)
buzzer = PWM(Pin(15, Pin.OUT))
buzzer.freq(4186)
buzzer.duty(0)
while True:
distance = ultrasonic.distance_cm()
print('Distance: ',distance,'cm','|',distance/2.54,'inch')
if distance <= 200:
led1.on()
#led2.off()
#led3.off()
buzzer.duty(0)
#elif
#buzzer.duty(0)
#elif
#buzzer.duty(512)
else:
led1.off()
#led2.off()
#led3.off()
sleep(5)