Skip to content

Add touch examples #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Feb 5, 2017
35 changes: 35 additions & 0 deletions libraries/ESP32/examples/Touch/touchIntrerrupt/touchIntrrerupt.ino
Original file line number Diff line number Diff line change
@@ -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 gotTouch(){
touch1detected = true;
}

void gotTouch1(){
touch2detected = true;
}

void setup() {
Serial.begin(115200);
delay(1000); // give me time to bring up serial monitor
printf("\n ESP32 Touch Interrupt Test\n");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be Serial.println("\nESP32 Touch Interrupt Test");

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

touchAttachInterrupt(T2, gotTouch, threshold);
touchAttachInterrupt(T3, gotTouch1, threshold);
}

void loop(){
if(touch1detected){
touch1detected = false;
Serial.println("Touch 1 detected");
}
if(touch2detected){
touch2detected = false;
Serial.println("Touch 2 detected");
}
}