code.py
 1  # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries
 2  # SPDX-License-Identifier: MIT
 3  """
 4  CircuitPython Capacitive Two Touch Pin Example - Print to the serial console when a pin is touched.
 5  
 6  Update TOUCH_PIN_ONE to the first touch-capable pin name for the board you're using.
 7  Update TOUCH_PIN_TWO to the pin name for the second touch-capable pin.
 8  
 9  For example:
10  If you are using A0 and A1 on a Feather RP2040, update TOUCH_PIN_ONE to A0 and TOUCH_PIN_TWO to A1.
11  """
12  import time
13  import board
14  import touchio
15  
16  touch_one = touchio.TouchIn(board.TOUCH_PIN_ONE)
17  touch_two = touchio.TouchIn(board.TOUCH_PIN_TWO)
18  
19  while True:
20      if touch_one.value:
21          print("Pin one touched!")
22      if touch_two.value:
23          print("Pin two touched!")
24      time.sleep(0.1)