# Importando módulos
import _thread
from machine import Pin
import time
# Creando objetos
cero = Pin(15, Pin.OUT)
uno = Pin(2, Pin.OUT)
dos = Pin(4, Pin.OUT)
tres = Pin(16, Pin.OUT)
cuatro = Pin(17, Pin.OUT)
cinco = Pin(5, Pin.OUT)
seis = Pin(18, Pin.OUT)
siete = Pin(19, Pin.OUT)
# Lista de LEDs
leds = [uno, dos, tres, cuatro, cinco, seis, siete]
# Función para mover luces a la derecha
def derecha():
while True:
for elemento in reversed(leds[4:]): # Corrección de índice
elemento.value(1) # Enciende LED
time.sleep(0.5)
elemento.value(0) # Apaga LED
time.sleep(0.2)
print("Derecha")
# Iniciar el hilo para la función derecha
_thread.start_new_thread(derecha, ())
# Función para mover luces a la izquierda
def izquierda():
while True:
for elemento in leds[:4]: # Corrección de índice
elemento.value(1) # Enciende LED
time.sleep(0.2)
elemento.value(0) # Apaga LED
time.sleep(0.2)
print("Izquierda")
# Bucle principal
while True:
izquierda()
time.sleep(1)