code.py
1 # SPDX-FileCopyrightText: 2021 Kattni Rembor for Adafruit Industries 2 # SPDX-License-Identifier: MIT 3 """ 4 CircuitPython Touch Input Example - Blinking an LED using a capacitive touch pad. 5 6 This example is meant for boards that have capacitive touch pads, and no simple way to wire up 7 a button. If there is a simple way to wire up a button, or a button built into the board, use 8 the standard Digital Input template and example. 9 10 Update TOUCH_PAD_PIN to the pin for the capacitive touch pad you wish you use. 11 12 For example: 13 If are using a BLM Badge and plan to use the first pad, change TOUCH_PAD_PIN to CAP1. 14 """ 15 import board 16 import digitalio 17 import touchio 18 19 led = digitalio.DigitalInOut(board.D13) 20 led.direction = digitalio.Direction.OUTPUT 21 22 touch = touchio.TouchIn(board.TOUCH_PAD_PIN) 23 24 while True: 25 if touch.value: 26 led.value = True 27 else: 28 led.value = False