-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from FoamyGuy/touchio_example
adding touchio example
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
""" | ||
This example shows how to use the debouncer library on the signals coming from | ||
a cap-sense pin with touchio. | ||
""" | ||
import time | ||
import board | ||
import touchio | ||
from adafruit_debouncer import Debouncer | ||
|
||
touch_pad = board.A1 | ||
touch = touchio.TouchIn(touch_pad) | ||
touch_debounced = Debouncer(touch) | ||
|
||
while True: | ||
touch_debounced.update() | ||
if touch_debounced.fell: | ||
print("Just released") | ||
if touch_debounced.rose: | ||
print("Just pressed") | ||
if touch_debounced.value: | ||
print("touching") | ||
else: | ||
# print('not touching') | ||
pass | ||
time.sleep(0.05) |