# Primero llamamos los modulos
from machine import Pin
from utime import sleep
# Segundo se crea el objeto
led_0 = Pin(18, Pin.OUT)
led_1 = Pin(5, Pin.OUT)
led_2 = Pin(17, Pin.OUT)
led_3 = Pin(16, Pin.OUT)
led_4 = Pin(4, Pin.OUT)
led_5 = Pin(0, Pin.OUT)
led_6 = Pin(2, Pin.OUT)
led_7 = Pin(15, Pin.OUT)
PARES = [0x2A]
IMPARES = [0xD5]
descarga = [255,254,252,248,240,224,192,128,0]
IND = 0
def port(Dato):
alr = list(bin(Dato)[2:])
print(alr)
lon = len(alr)
print(lon)
for e in range(lon):
if alr[e] == '0':
alr[e] = 0
else:
alr[e] = 1
print(alr)
for i in range(8-lon):
alr.insert(0,0)
print(alr)
led_0.value(alr[0])
led_1.value(alr[1])
led_2.value(alr[2])
led_3.value(alr[3])
led_4.value(alr[4])
led_5.value(alr[5])
led_6.value(alr[6])
led_7.value(alr[7])
# Desarrolla mos el cilo y el codigo
while True:
IND = 0
port(PARES[IND])
sleep(1)
IND += 1
IND = 0
port(IMPARES[IND])
sleep(1)
IND += 1
IND = 0
port(PARES[IND])
sleep(1)
IND += 1
IND = 0
port(IMPARES[IND])
sleep(1)
IND += 1
IND = 0
port(PARES[IND])
sleep(1)
IND += 1
IND = 0
port(IMPARES[IND])
sleep(1)
IND += 1
IND = 0
port(PARES[IND])
sleep(1)
IND += 1
IND = 0
port(IMPARES[IND])
sleep(1)
IND += 1
IND = 0
port(descarga[IND])
sleep(1)
IND += 1
port(descarga[IND])
sleep(1)
IND += 1
port(descarga[IND])
sleep(1)
IND += 1
port(descarga[IND])
sleep(1)
IND += 1
port(descarga[IND])
sleep(1)
IND += 1
port(descarga[IND])
sleep(1)
IND += 1
port(descarga[IND])
sleep(1)
IND += 1
port(descarga[IND])
sleep(1)
IND += 1
port(descarga[IND])
sleep(1)
IND += 1