# the imports
from machine import Pin
import time
# basic variables
red_led = Pin(2,Pin.OUT)
switch = Pin(4,Pin.IN)
# main code loop
while True:
# more variables
switch_state = switch.value()
print("switch state:" + str(switch_state))
# the main code / figuring out when to on and off the led based on the slide switch
if switch_state == 1:
red_led.value(1)
else:
red_led.value(0)
time.sleep(0.1)