import machine
from machine import Pin
#Salidas led verde: 4 ; led azul: 2; led rojo: 1
ledRojo = Pin(1, Pin.OUT)
ledAzul = Pin(2,Pin.OUT)
ledVerde = Pin(3,Pin.OUT)
#Entradas primer bit slider A, segundo bit slider B, tercer bit slider C
SliderA = Pin(4, Pin.IN,Pin.PULL_UP)
SliderB = Pin(5, Pin.IN,Pin.PULL_UP)
SliderC = Pin(6, Pin.IN,Pin.PULL_UP)
SliderD = Pin(7, Pin.IN,Pin.PULL_UP)
#Hice tabla de valor y karnaugh con cada bit
while True:
A = SliderA.value()
B = SliderB.value()
C = SliderC.value()
D = SliderD.value()
bitCuatro = ( (A and C) or (A and B and D) or (B and C and D) )
ledVerde.value(bitCuatro)
bitDos = ( (A and not B and not C) or (A and not C and not D) or (not A and C and not D) or (not A and not B and C) or (A and B and C and D) or (not A and B and not C and D) )
ledAzul.value(bitDos)
bitUno = ( ( B and not D) or (not B and D) )
ledRojo.value(bitUno)