# LED control using keys/switch with internal pull_down resistor.
from machine import Pin
from time import sleep
led = Pin(5, Pin.OUT)
switch = Pin(27,Pin.IN, Pin.PULL_DOWN)
while True:
x = switch.value()
if x==1:
led.on()
else:
led.off()