from machine import Pin
import time
SWITCH = 2
RED_LED = 22
GREEN_LED = 21
BLUE_LED = 19
YELLOW_LED = 18
# Configure pins
switch = Pin(SWITCH, Pin.IN, Pin.PULL_UP)
red_led = Pin(RED_LED, Pin.OUT)
green_led = Pin(GREEN_LED, Pin.OUT)
blue_led = Pin(BLUE_LED, Pin.OUT)
yellow_led = Pin(YELLOW_LED, Pin.OUT)
switch_condition = False
while True:
# Read switch state
switch_condition = switch.value()
if switch_condition == 0:
# Switch is OFF
blue_led.on()
yellow_led.on()
red_led.off()
green_led.on()
time.sleep(1)
red_led.on()
green_led.off()
time.sleep(1)
else:
# Switch is ON
red_led.on()
green_led.on()
blue_led.on()
yellow_led.off()
time.sleep(1)
blue_led.off()
yellow_led.on()
time.sleep(1)