import machine
import time
#Define the GPIO pins for the LED and push button
LED_PIN = 0
BUTTON_PIN = 14
#Initialize the LED pin as an output and the button pin as an input with a pull-up resistor
led = machine.Pin(LED_PIN, machine.Pin.OUT)
button = machine.Pin(BUTTON_PIN, machine.Pin.IN,
machine.Pin.PULL_UP)
while True:
if not button.value(): #Check if the button is pressed (LOW)
led.on() #Turn on the LED
print("LED ON!")
time.sleep(0.5)
else:
led.off() # Turn off the LED
print("LED OFF!")
time.sleep (0.5)