# Importing necessary modules
from machine import Pin
from time import sleep
# Input pin configuration for slide switches
switch1 = Pin(6, Pin.IN) # Switch1 connected to pin 6
switch2 = Pin(7, Pin.IN) # Switch2 connected to pin 7
# Output pin configuration for RGB LED
red = Pin(18, Pin.OUT) # Red LED connected to pin 18
green = Pin(17, Pin.OUT) # Green LED connected to pin 17
blue = Pin(16, Pin.OUT) # Blue LED connected to pin 16
while True:
# Reading states of the slide switches
sw1_state = switch1.value()
sw2_state = switch2.value()
# Printing the states of the switches
print("Switch1:", sw1_state, "Switch2:", sw2_state)
# LED logic based on the switch states
if sw1_state == 1 and sw2_state == 1:
red.value(1) # Red LED ON
green.value(0) # Green LED OFF
blue.value(0) # Blue LED OFF
elif sw1_state == 1 and sw2_state == 0:
red.value(0) # Red LED OFF
green.value(1) # Green LED ON
blue.value(0) # Blue LED OFF
elif sw1_state == 0 and sw2_state == 1:
red.value(0) # Red LED OFF
green.value(0) # Green LED OFF
blue.value(1) # Blue LED ON
else:
red.value(1) # Red LED ON
green.value(1) # Green LED ON
blue.value(1) # Blue LED ON
sleep(0.1) # Wait for 0.1 seconds before checking again0
1
0
1