code.py
 1  # SPDX-FileCopyrightText: 2019 Kattni Rembor for Adafruit Industries
 2  #
 3  # SPDX-License-Identifier: MIT
 4  
 5  """Simple example to print when switch is pressed"""
 6  import time
 7  import digitalio
 8  import board
 9  
10  switch = digitalio.DigitalInOut(board.D9)
11  switch.switch_to_input(pull=digitalio.Pull.UP)
12  
13  while True:
14      if not switch.value:
15          print("Switch pressed!")
16      time.sleep(0.1)