File tree 1 file changed +35
-0
lines changed
libraries/ESP32/examples/Touch/TouchInterrupt
1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change
1
+ /*
2
+ This is un example howto use Touch Intrrerupts
3
+ The bigger the threshold, the more sensible is the touch
4
+ */
5
+
6
+ int threshold = 40 ;
7
+ bool touch1detected = false ;
8
+ bool touch2detected = false ;
9
+
10
+ void gotTouch1 (){
11
+ touch1detected = true ;
12
+ }
13
+
14
+ void gotTouch2 (){
15
+ touch2detected = true ;
16
+ }
17
+
18
+ void setup () {
19
+ Serial.begin (115200 );
20
+ delay (1000 ); // give me time to bring up serial monitor
21
+ Serial.println (" ESP32 Touch Interrupt Test" );
22
+ touchAttachInterrupt (T2, gotTouch1, threshold);
23
+ touchAttachInterrupt (T3, gotTouch2, threshold);
24
+ }
25
+
26
+ void loop (){
27
+ if (touch1detected){
28
+ touch1detected = false ;
29
+ Serial.println (" Touch 1 detected" );
30
+ }
31
+ if (touch2detected){
32
+ touch2detected = false ;
33
+ Serial.println (" Touch 2 detected" );
34
+ }
35
+ }
You can’t perform that action at this time.
0 commit comments