Skip to content

Commit 0961c83

Browse files
committed
adding touchio example
1 parent 3569774 commit 0961c83

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

examples/debouncer_touchio_test.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
"""
2+
This example shows how to use the debouncer library on the signals coming from
3+
a cap-sense pin with touchio.
4+
"""
5+
import time
6+
import board
7+
import touchio
8+
from adafruit_debouncer import Debouncer
9+
10+
touch_pad = board.A1
11+
touch = touchio.TouchIn(touch_pad)
12+
touch_debounced = Debouncer(touch)
13+
14+
while True:
15+
touch_debounced.update()
16+
if touch_debounced.fell:
17+
print("Just released")
18+
if touch_debounced.rose:
19+
print("Just pressed")
20+
if touch_debounced.value:
21+
print("touching")
22+
else:
23+
# print('not touching')
24+
pass
25+
time.sleep(0.05)

0 commit comments

Comments
 (0)