from machine import Pin
import time
# Pin assignments for LEDs
led1 = Pin(12, Pin.OUT)
led2 = Pin(14, Pin.OUT)
led3 = Pin(27, Pin.OUT)
led4 = Pin(26, Pin.OUT)
# Pin assignments for buttons (switches)
sw1 = Pin(19, Pin.IN, Pin.PULL_UP)
sw2 = Pin(21, Pin.IN, Pin.PULL_UP)
sw3 = Pin(22, Pin.IN, Pin.PULL_UP)
sw4 = Pin(23, Pin.IN, Pin.PULL_UP)
while True:
# Control LEDs based on the switch status
led1.value(not sw1.value()) # Turn LED1 on when SW1 is pressed
led2.value(not sw2.value()) # Turn LED2 on when SW2 is pressed
led3.value(not sw3.value()) # Turn LED3 on when SW3 is pressed
led4.value(not sw4.value()) # Turn LED4 on when SW4 is pressed
time.sleep(0.1) # Small delay to debounce the switches