from machine import Pin
from time import ticks_ms
ledG = Pin(1, Pin.OUT)
ledY = Pin(2, Pin.OUT)
ledR = Pin(3, Pin.OUT)
tanahora = ticks_ms()
estado = "pare"
while True:
if ticks_ms() >= tanahora:
if estado == "pare":
ledR.on()
ledG.off()
ledY.off()
tanahora = ticks_ms() +5000
estado = "Cuidado"
elif estado == "Cuidado":
ledR.off()
ledG.off()
ledY.on()
tanahora = ticks_ms() +2000
estado = "siga"
else:
estado == "siga"
ledR.off()
ledG.on()
ledY.off()
tanahora = ticks_ms()+7000
estado = "pare"