from hcsr04 import* from time import* c=HCSR04(trig=14,echo=27) b=Pin(17,Pin.IN) s=PWM(Pin(32,Pin.OUT)) s.freq(50) rt=Pin(25,Pin.OUT) bt=Pin(26,Pin.OUT) rv=Pin(23,Pin.OUT) ov=Pin(22,Pin.OUT) vv=Pin(21,Pin.OUT) rp=Pin(19,Pin.OUT) vp=Pin(18,Pin.OUT) while True: d=c.distance() if d<200: rv.on() rp.on() vp.off() 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() if b.value()==0: vp.on() rp.off() else: vp.off() rp.on() rv.off() vv.on() sleep(1) vv.off() for i in range(3): ov.on() sleep(0.2) ov.off() sleep(0.2) rv.on() sleep(1)
|
Aucun commentaire:
Enregistrer un commentaire