from machine import Pin
import time
boton_cruce = Pin(22, Pin.IN, Pin.PULL_DOWN)
boton_reset = Pin(21, Pin.IN, Pin.PULL_DOWN)
led_rojo = Pin(0, Pin.OUT)
led_amarillo = Pin(1, Pin.OUT)
led_verde = Pin(2, Pin.OUT)
led_peaton = Pin(3, Pin.OUT)
estado = 0
while True:
if boton_cruce.value() == 1:
estado = 1
time.sleep(0.2)
if boton_reset.value() == 1:
estado = 0
time.sleep(0.2)
if estado == 0:
led_rojo.off()
led_amarillo.off()
led_verde.on()
led_peaton.off()
elif estado == 1:
led_rojo.on()
led_amarillo.off()
led_verde.off()
led_peaton.on()