import machine
import utime
# Define the GPIO pin connected to the slide switch
SWITCH_PIN = machine.Pin(15, machine.Pin.IN)
# Main loop to detect the state of the slide switch
while True:
# Read the state of the slide switch
switch_state = SWITCH_PIN.value()
# Output the state of the slide switch
if switch_state == 0:
print("Slide switch is in ON position")
else:
print("Slide switch is in OFF position")
# Wait for a short time before checking the switch again
utime.sleep(0.1)