from machine import Pin
import utime
# Define slide switch pins
switch_pin = Pin(0, Pin.IN) # GPIO pin 0
led=Pin(5,Pin.OUT)
while True:
# Read switch state
switch_state = switch_pin.value()
# Print switch state
if switch_state == 1:
led.on()
print("Switch is ON")
else:
led.off()
print("Switch is OFF")
utime.sleep(0.1) # Delay to avoid rapid switching and print flickering