#led1 - gp2
#led2 - gp3
#led3 - gp3
#dipSwitch - gp6 al gp13
from machine import Pin
import time
# Entradas A
A = [Pin(0, Pin.IN, Pin.PULL_DOWN),
Pin(1, Pin.IN, Pin.PULL_DOWN),
Pin(2, Pin.IN, Pin.PULL_DOWN),
Pin(3, Pin.IN, Pin.PULL_DOWN)]
# Entradas B
B = [Pin(4, Pin.IN, Pin.PULL_DOWN),
Pin(5, Pin.IN, Pin.PULL_DOWN),
Pin(6, Pin.IN, Pin.PULL_DOWN),
Pin(7, Pin.IN, Pin.PULL_DOWN)]
# Salidas
led_mayor = Pin(10, Pin.OUT)
led_igual = Pin(11, Pin.OUT)
led_menor = Pin(12, Pin.OUT)
def leer(bits):
valor = 0
for i in range(4):
valor |= bits[i].value() << i
return valor
while True:
a = leer(A)
b = leer(B)
led_mayor.off()
led_igual.off()
led_menor.off()
if a > b:
led_mayor.on()
elif a == b:
led_igual.on()
else:
led_menor.on()
time.sleep(0.1)