Skip to content

Commit 0d50275

Browse files
authored
Merge pull request #1499 from kattni/touch-input-template
Add touch input template example code.
2 parents a1c2234 + ae8e557 commit 0d50275

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

CircuitPython_Templates/neopixel_blink.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
"""
22
CircuitPython NeoPixel Blink example - blinking the built-in NeoPixel(s).
33
4+
This example is meant for boards that have built-in NeoPixel LEDs but do not have a little
5+
red LED. If a little red LED is present, use the standard Blink template and example.
6+
47
Update NUMBER_OF_PIXELS to the match the number of built-in NeoPixels on the board.
58
69
DO NOT INCLUDE THE pylint: disable LINE IN THE GUIDE CODE. It is present only to deal with the
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
"""
2+
CircuitPython Touch Input Example - Blinking an LED using a capacitive touch pad.
3+
4+
This example is meant for boards that have capacitive touch pads, and no simple way to wire up
5+
a button. If there is a simple way to wire up a button, or a button built into the board, use
6+
the standard Digital Input template and example.
7+
8+
Update TOUCH_PAD_PIN to the pin for the capacitive touch pad you wish you use.
9+
10+
For example:
11+
If are using a BLM Badge and plan to use the first pad, change TOUCH_PAD_PIN to CAP1.
12+
"""
13+
import board
14+
import digitalio
15+
import touchio
16+
17+
led = digitalio.DigitalInOut(board.D13)
18+
led.direction = digitalio.Direction.OUTPUT
19+
20+
touch = touchio.TouchIn(board.TOUCH_PAD_PIN)
21+
22+
while True:
23+
if touch.value:
24+
led.value = True
25+
else:
26+
led.value = False

0 commit comments

Comments
 (0)