From c66b54a9ebd00347060b01738418d4c96b72de32 Mon Sep 17 00:00:00 2001 From: Ion Date: Sun, 5 Feb 2017 18:03:04 +0200 Subject: [PATCH] Add touch example --- .../Touch/TouchInterrupt/TouchInterrupt.ino | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 libraries/ESP32/examples/Touch/TouchInterrupt/TouchInterrupt.ino diff --git a/libraries/ESP32/examples/Touch/TouchInterrupt/TouchInterrupt.ino b/libraries/ESP32/examples/Touch/TouchInterrupt/TouchInterrupt.ino new file mode 100644 index 00000000..8f40382c --- /dev/null +++ b/libraries/ESP32/examples/Touch/TouchInterrupt/TouchInterrupt.ino @@ -0,0 +1,35 @@ +/* +This is un example howto use Touch Intrrerupts +The bigger the threshold, the more sensible is the touch +*/ + +int threshold = 40; +bool touch1detected = false; +bool touch2detected = false; + +void gotTouch1(){ + touch1detected = true; +} + +void gotTouch2(){ + touch2detected = true; +} + +void setup() { + Serial.begin(115200); + delay(1000); // give me time to bring up serial monitor + Serial.println("ESP32 Touch Interrupt Test"); + touchAttachInterrupt(T2, gotTouch1, threshold); + touchAttachInterrupt(T3, gotTouch2, threshold); +} + +void loop(){ + if(touch1detected){ + touch1detected = false; + Serial.println("Touch 1 detected"); + } + if(touch2detected){ + touch2detected = false; + Serial.println("Touch 2 detected"); + } +}