from machine import Pin
import time

def valida(num):
    return num < 32

def numero_binario(num):
    if valida(num):
        binario = [0, 0, 0, 0, 0]
        for i in range(5):
            binario[i] = num % 2
            num = num // 2
        return list(reversed(binario))
    else:
        raise ValueError("El numero sobrepasa los bits soportados")

led_pins = [10, 11, 12, 13, 14]
leds = [Pin(pin, Pin.OUT) for pin in led_pins]
button_pin = Pin(15, Pin.IN, Pin.PULL_DOWN)

print("Inicio del programa...")

while True:
    if button_pin.value() == 1:
        print("Botón presionado, iniciando conteo binario...")
        for i in range(32):
            n = numero_binario(i)
            print(f"Contador: {i}, Binario: {n}")
            for j in range(5):
                leds[j].value(n[j])
                print(f"LED {led_pins[j]} {'ON' if n[j] else 'OFF'}")
            time.sleep(1)
        time.sleep(0.5)
    else:
        for led in leds:
            led.value(0)


$abcdeabcde151015202530354045505560fghijfghij
BOOTSELLED1239USBRaspberryPiPico©2020RP2-8020/21P64M15.00TTT