from machine import Pin,PWM
from time import sleep
auto_verte = Pin(3, Pin.OUT)
auto_rojo = Pin(9, Pin.OUT)
peaton = Pin(2, Pin.OUT)
boton = Pin(17, Pin.IN, Pin.PULL_DOWN)
buzzer = PWM(Pin(15))
while True:
auto_verde.on()
auto_rojo.off()
peaton.off()
buzzer.duty_u16(0)
if boton.value() == 1:
buzzer.freq(1000)
buzzer.duty_u16(30000)
auto_verte.off()
auto_rojo.on()
sleep(1)
peaton.on()
sleep(4)
peaton.off()
sleep(1)
auto_rojo.off()
sleep(0.5)