from machine import Pin,PWM
from time import sleep
capteur=Pin(12,Pin.IN)
led=Pin(0,Pin.OUT)
buzzer=PWM(Pin(25))
buzzer.freq(1000)
rouge=Pin(19,Pin.OUT)
vert=Pin(18,Pin.OUT)
blue=Pin(5,Pin.OUT)
def allumerRouge():
blue.off()
vert.off()
rouge.on()
def allumerVert():
blue.off()
vert.on()
rouge.off()
buzzer.duty_u16(0)
while True:
if(capteur.value()==1):
allumerRouge()
print("detection")
led.on()
buzzer.duty_u16(3000)
sleep(0.5)
else:
allumerVert()
buzzer.duty_u16(0)