code.py
 1  # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  """
 6  Button example for Pico. Prints message to serial console when button is pressed.
 7  
 8  REQUIRED HARDWARE:
 9  * Button switch on pin GP13.
10  """
11  import time
12  import board
13  import digitalio
14  
15  button = digitalio.DigitalInOut(board.GP13)
16  button.switch_to_input(pull=digitalio.Pull.DOWN)
17  
18  while True:
19      if button.value:
20          print("You pressed the button!")
21          time.sleep(0.5)