import machine
from machine import Pin
#Salidas
ledRojo = Pin(1, Pin.OUT)
ledAzul = Pin(0, Pin.OUT)
ledVerde = Pin(2, Pin.OUT)
ledAmarillo = Pin(3, Pin.OUT)
#Entradas de seleccion
selectorS1 = Pin(4, Pin.IN,Pin.PULL_UP)
selectorS0 = Pin(5, Pin.IN,Pin.PULL_UP)
#Entradas de datos
datoE = Pin(6, Pin.IN,Pin.PULL_UP)
#Demultiplexor de 1 entrada de dato, 2 entradas de seleccion y 4 salidas
while True:
S1 = selectorS1.value()
S0 = selectorS0.value()
E = datoE.value()
if (E == 1):
salidaA = (E and not S1 and not S0)
ledAmarillo.value(salidaA)
salidaB = (E and not S1 and S0)
ledVerde.value(salidaB)
salidaC = (E and S1 and not S0)
ledAzul.value(salidaC)
salidaD = (E and S1 and S0)
ledRojo.value(salidaD)
else:
ledAmarillo.value(0)
ledVerde.value(0)
ledAzul.value(0)
ledRojo.value(0)