from machine import Pin
from time import sleep
# Define inputs for slide switches
switch1 = Pin(2, Pin.IN) # Slide Switch 1 on GP1
switch2 = Pin(3, Pin.IN) # Slide Switch 2 on GP0
# Define output for LED
led = Pin(14, Pin.OUT) # LED on GP14
while True:
# Read switch states (1 = ON, 0 = OFF)
sw1_state = switch1.value()
sw2_state = switch2.value()
print("Switch 1 state:", sw1_state)
print("Switch 2 state:", sw2_state)
led.value(0) # LED stays OFF
# AND Condition: LED ON only if switch 1 is ON and switch 2 is OFF
if sw1_state == 1 & sw2_state == 1:
led.value(1) # LED stays ON
sleep(0.1) # Small delay to avoid rapid printing