from machine import Pin
import time
# Entradas
A = Pin(2, Pin.IN, Pin.PULL_DOWN)
B = Pin(3, Pin.IN, Pin.PULL_DOWN)
C = Pin(4, Pin.IN, Pin.PULL_DOWN)
# Salidas
Y_ext = Pin(15, Pin.OUT)
Y_simp = Pin(16, Pin.OUT)
IGUAL = Pin(17, Pin.OUT)
while True:
a = A.value()
b = B.value()
c = C.value()
# Funcion extendida
y_ext = ((not a) and (not b) and (not c)) or \
((not a) and b and (not c)) or \
((not a) and b and c) or \
(a and b and c)
# Funcion simplificada
y_simp = ((not a) and (not c)) or (b and c)
# Convertir a 0 o 1
y_ext = int(y_ext)
y_simp = int(y_simp)
# Mostrar resultados
Y_ext.value(y_ext)
Y_simp.value(y_simp)
# Comprobar igualdad
IGUAL.value(y_ext == y_simp)
print("A =", a,
" B =", b,
" C =", c,
" | Y_ext =", y_ext,
" | Y_simp =", y_simp,
" | IGUALES =", y_ext == y_simp)
time.sleep(0.2)