from machine import Pin
from time import ticks_ms
ledRed = Pin(3, Pin.OUT)
ledGreen = Pin(1, Pin.OUT)
ledYellow = Pin(2, Pin.OUT)
bot = Pin(8, Pin.IN, Pin.PULL_DOWN)
b = bAnt = bot.value()
estado = "SIGA EM FRENTE"
tempo = 0
while True:
if ticks_ms() >= tempo:
if estado == "SIGA EM FRENTE":
ledGreen.off()
ledYellow.on()
ledRed.off()
tempo = ticks_ms() + 2000
estado = "ATENCAO"
elif estado == "ATENCAO":
ledGreen.off()
ledYellow.off()
ledRed.on()
tempo = ticks_ms() + 5000
estado = "PARE"
elif estado == "PARE":
ledGreen.on()
ledYellow.off()
ledRed.off()
tempo = ticks_ms() + 7000
estado = "SIGA EM FRENTE"
b = bot.value()
if b != bAnt:
if b == 1 and estado == "SIGA EM FRENTE":
if (tempo - ticks_ms()) > 2000:
tempo = ticks_ms() + 2000
print('botão ativo')
bAnt = b Loading
aitewinrobot-esp32c3-supermini
aitewinrobot-esp32c3-supermini