Add touch input template example code.
This commit is contained in:
parent
a1c22349c7
commit
ae8e5576b4
2 changed files with 29 additions and 0 deletions
|
|
@ -1,6 +1,9 @@
|
|||
"""
|
||||
CircuitPython NeoPixel Blink example - blinking the built-in NeoPixel(s).
|
||||
|
||||
This example is meant for boards that have built-in NeoPixel LEDs but do not have a little
|
||||
red LED. If a little red LED is present, use the standard Blink template and example.
|
||||
|
||||
Update NUMBER_OF_PIXELS to the match the number of built-in NeoPixels on the board.
|
||||
|
||||
DO NOT INCLUDE THE pylint: disable LINE IN THE GUIDE CODE. It is present only to deal with the
|
||||
|
|
|
|||
26
CircuitPython_Templates/touch_input.py
Normal file
26
CircuitPython_Templates/touch_input.py
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
"""
|
||||
CircuitPython Touch Input Example - Blinking an LED using a capacitive touch pad.
|
||||
|
||||
This example is meant for boards that have capacitive touch pads, and no simple way to wire up
|
||||
a button. If there is a simple way to wire up a button, or a button built into the board, use
|
||||
the standard Digital Input template and example.
|
||||
|
||||
Update TOUCH_PAD_PIN to the pin for the capacitive touch pad you wish you use.
|
||||
|
||||
For example:
|
||||
If are using a BLM Badge and plan to use the first pad, change TOUCH_PAD_PIN to CAP1.
|
||||
"""
|
||||
import board
|
||||
import digitalio
|
||||
import touchio
|
||||
|
||||
led = digitalio.DigitalInOut(board.D13)
|
||||
led.direction = digitalio.Direction.OUTPUT
|
||||
|
||||
touch = touchio.TouchIn(board.TOUCH_PAD_PIN)
|
||||
|
||||
while True:
|
||||
if touch.value:
|
||||
led.value = True
|
||||
else:
|
||||
led.value = False
|
||||
Loading…
Reference in a new issue