diff --git a/examples/debouncer_touchio_test.py b/examples/debouncer_touchio_test.py new file mode 100644 index 0000000..260419c --- /dev/null +++ b/examples/debouncer_touchio_test.py @@ -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)