from hcsr04 import*
from time import*
c=HCSR04(trig=12,echo=13)
s=PWM(Pin(22,Pin.OUT))
s.freq(50)
rt=Pin(25,Pin.OUT)
bt=Pin(26,Pin.OUT)
while True:
d=c.distance()
if d<300:
s.duty(75)
rt.on()
bt.off()
sleep(0.2)
bt.on()
rt.off()
sleep(0.2)
else:
s.duty(27)
rt.off()
bt.off()