import board
from digitalio import DigitalInOut, Direction, Pull
import time
led = DigitalInOut(board.GP15)
button = DigitalInOut(board.GP14)
led.direction = Direction.OUTPUT
button.direction = Direction.INPUT
button.pull = Pull.UP # Pull: defines the pull of a digital input pin
buttonState = False
while True:
buttonState = button.value
if buttonState:
# button is pressed and led is currently on
led.value = False
print("LED IS OFF")
else:
# button is pressed and led is currently off
led.value = True
print("LED IS ON")
time.sleep(0.01)