import machine 
from machine import Pin

#ENTRADAS
slideA = Pin(1,Pin.IN)
slideB = Pin(2,Pin.IN)
slideC = Pin(0,Pin.IN)
slideD = Pin(4,Pin.IN)

#SALIDAS
ROJO_S0= Pin(13,Pin.OUT)
VERDE_S1= Pin(2,Pin.OUT)
AZUL_CYOUT= Pin(3,Pin.OUT)

while True:
    A1= slideA.value()
    A0= slideB.value()
    B1= slideC.value()
    B0= slideD.value()

    #HALF_ADDER
    S0 = (( (not A0) and B0) or (A0 and (not B0)))
    carryIN= (A0 and B0)
    #FULL_ADDER
    S1 = (not(((not A1) and B1) or (A1 and (not B1))) and carryIN) or ((((not A1) and B1) or (A1 and (not B1))) and (not carryIN))
    carryOUT = (A1 and B1) or (B1 and carryIN) or (A1 and carryIN)

    ROJO_S0.value(S0)
    VERDE_S1.value(S1)
    AZUL_CYOUT.value(carryOUT)