# 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 pull down resistor for the switch connection
# resistor : 220 ohm
from machine import Pin
led_pin = Pin(2, Pin.OUT)
switch_pin = Pin(14, Pin.IN, Pin.PULL_DOWN)
while True:
switch_state = switch_pin.value()
if switch_state == 1:
led_pin.on()
else:
led_pin.off()