import board
import digitalio
import time
led = digitalio.DigitalInOut(board.GP26) # Set the PIN to IO
button = digitalio.DigitalInOut(board.GP27) # Set the button Pin to the button (2
led.direction = digitalio.Direction.OUTPUT # Declare the LED object as an ouput
button.direction = digitalio.Direction.INPUT # Declare the buton as an input.
button.pull = digitalio.Pull.DOWN # Note that no action will be taken if the button is not pressed.
while True: # Loop for the board to execute the function and continue to do
state = button.value # Declare the state as the button value
if state == True: # Establish a condition to turn on
led.value = True # If the button is pressed, the LED will light up
else:
led.value = False # If the button is not pressed, the LED will not light up
C I R C U I T P Y T H O N