from machine import Pin
from time import sleep
# Define GPIO pins for switches and LEDs
left_switch = Pin(2, Pin.IN) # Left switch (GP-2) as input
right_switch = Pin(3, Pin.IN) # Right switch (GP-3) as input
led = Pin(14, Pin.OUT) # Left LED (GP-14) as output
while True:
left_state = left_switch.value() # Read left switch state
right_state = right_switch.value() # Read right switch state
print("Left switch: ",left_state) # print the state of left switch
print("Right switch: ",right_state)# print the state of right switch
if left_state == 1 and right_state == 0: # If only left switch is ON
led.value(1) # Turn ON left LED
sleep(0.5) # Wait 0.5 seconds
led.value(0) # Turn OFF left LED
sleep(0.5) # Wait 0.5 seconds
else: # If both switches are ON or both switches are OFF
led.value(0) # Keep left LED OFF
sleep(0.1) # Small delay