# Write a programe to control onBoard LED W.R.T position of onBoard switch
from machine import Pin
import time
button_pin = 0
led_pin = 2
led = Pin(led_pin, Pin.OUT)
button = Pin(button_pin, Pin.IN, Pin.PULL_UP)
while True:
button_state = button.value()
if button_state == 0:
led.on()
else:
led.off()
# Add a small delay to avoid rapid readings
time.sleep(0.1)