from machine import Pin
import time
import random
#salidas Leds
Led1 = Pin(19, Pin.OUT) # create output pin on GPIO0
Led2 = Pin(18, Pin.OUT)
Led3 = Pin(5, Pin.OUT)
Led4 = Pin(17, Pin.OUT)
Leds=[Led1,Led2,Led3,Led4]
def conversion(decimal):
binario=""
while decimal/2!=0:
binario=str(decimal%2)+binario
decimal=decimal//2
print("binario: ", binario)
while len(binario)!=4:
binario="0"+binario
return binario
while True:
numero=int(input("Ingrese decimal: "))
conv= conversion(numero)
print(conv)
for i in range(len(conv)):
if conv[i]=="1": Leds[i].on()
else: Leds[i].off()