from machine import Pin
import time
# Define input switches
Sw1 = Pin(14, Pin.IN, Pin.PULL_DOWN) # Input A
Sw2 = Pin(15, Pin.IN, Pin.PULL_DOWN) # Input B
# Define output LEDs
led_and = Pin(0, Pin.OUT)
led_or = Pin(1, Pin.OUT)
led_not = Pin(2, Pin.OUT)
while True:
A = Sw1.value()
B = Sw2.value()
# Logic operations
led_and.value(A and B)
led_or.value(A or B)
# Use NOT of B instead of A (so it changes when you press SW2)
led_not.value(1 - A)
time.sleep(0.1)