import machine
from machine import Pin
LedRojo = Pin(12,Pin.OUT)
LedAmarillo = Pin(14,Pin.OUT)
LedCarryAzul = Pin(27,Pin.OUT)
Entrada1 = Pin(21,Pin.IN,Pin.PULL_UP)
Entrada2 = Pin(19,Pin.IN,Pin.PULL_UP)
Entrada3 = Pin(18,Pin.IN,Pin.PULL_UP)
Entrada4 = Pin(5,Pin.IN,Pin.PULL_UP)
while True:
A=Entrada1.value()
B=Entrada2.value()
C=Entrada3.value()
D=Entrada4.value()
suma = ((B and (not D)) or ((not B) and D))
carry = (B and D)
suma2 = ((not A) and (not C) and carry) or ((not A) and C and (not carry)) or (A and (not C) and (not carry)) or (A and C and carry)
carry2 = (A and (C or carry)) or (C and (A or carry)) or (carry and (A or C))
LedRojo.value(suma)
LedAmarillo.value(suma2)
LedCarryAzul.value(carry2)