import machine
from machine import Pin
#Salidas
ledRojo = Pin(1, Pin.OUT)
#Entradas de seleccion
selectorS1 = Pin(4, Pin.IN,Pin.PULL_UP)
selectorS0 = Pin(5, Pin.IN,Pin.PULL_UP)
#Entradas de datos
datoA = Pin(6, Pin.IN,Pin.PULL_UP)
datoB = Pin(7, Pin.IN,Pin.PULL_UP)
datoC = Pin(8, Pin.IN,Pin.PULL_UP)
datoD = Pin(9, Pin.IN,Pin.PULL_UP)
#Multiplexor de 4 entradas de datos, 2 entradas de seleccion y 1 salida
while True:
A = selectorS1.value()
B = selectorS0.value()
res = 0
if (not A and not B):
res = datoA.value()
if (not A and B):
res = datoB.value()
if (A and not B):
res = datoC.value()
if (A and B):
res = datoD.value()
ledRojo.value(res)