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