#6 Write a micropython script to control an led connected to GPIO2 of esp32 with respect to the position of the switch key GPIO14.
# If the switch is on led should be on vice-versa
# note : use external resistor for the switch connection
# resistor : 220 ohm
from machine import Pin
import time
ledpin = 2
switchpin = 14
led = Pin(ledpin, Pin.OUT)
switch = Pin(switchpin, Pin.IN)
while True:
switchstate = switch.value()
if switchstate == 1:
led.value(1)
else:
led.value(0)