""" micropython ESP32
Led parpadeante con micropython """
# incluir librerías de boot.py
from machine import Pin # configurar pines
from time import sleep # configurar retrasos
# crear variables o puertos
r1 = Pin(21,Pin.OUT)
a1 = Pin(19,Pin.OUT)
v1 = Pin(18,Pin.OUT)
r2 = Pin(5,Pin.OUT)
a2 = Pin(17,Pin.OUT)
v2 = Pin(16,Pin.OUT)
# Para peatones
r3 = Pin(23,Pin.OUT)
v3 = Pin(22,Pin.OUT)
r4 = Pin(4,Pin.OUT)
v4 = Pin(2,Pin.OUT)
# construir ciclo infinito (loop ARDUINO)
while True: #Construir ciclo infinito
v1.value(1) # Secuencia 1, led verde ON
r2.value(1) # led rojo 2 ON
sleep(3) # retardo de 3s
v1.value(0) # Secuencia 2, led verde OFF
for i in range(5): # ciclo de ambar 1 finito 5 tiempos
a1.value(1) # led ambar ON
sleep(0.5) # retardo de 0.5s
a1.value(0) # led ambar OFF
sleep(0.5) # retardo de 0.5s
r1.value(1) # Secuencia 3, led rojo ON
r2.value(0) # led rojo 2 OFF
v2.value(1) # led verde 2 OFF
sleep(3) # retardo de 3 s
v2.value(0) # Secuencia 4, verde 2 OFF
for i in range(5): # ciclo de ambar 2 finito 5 tiempos
a2.value(1) # led ambar 2 ON
sleep(0.5) # retardo de 0.5s
a2.value(0) # led ambar 2 OFF
sleep(0.5) # retardo de 0.5s
r1.value(0) # Secuencia 5, rojo OFF