Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* T0 T3 T4 T5
- T0 GPIO 4 T0 G4 G15 G13 G12
- T1 GPIO 0 nao usar
- T2 GPIO 2 nao usar 1 2 3 A G14 T6
- T3 GPIO 15 T3 4 5 6 B G27 T7
- T4 GPIO 13 T4 7 8 9 C G32 T8
- T5 GPIO 12 T5 * 0 # D G33 T9
- T6 GPIO 14 T6
- T7 GPIO 27 T7
- T8 GPIO 32 T8
- T9 GPIO 33 T9
- */
- #define THRESHOLD 70
- int col1 = 0;
- int col2 = 0;
- int col3 = 0;
- int col4 = 0;
- int row1 = 0;
- int row2 = 0;
- int row3 = 0;
- int row4 = 0;
- //---------------------------------------------------------
- void printout()
- {
- /*
- Serial.print("(T0) "); Serial.println(col1); // get value using T0
- Serial.print("(T3) "); Serial.println(col2); // get value using T3
- Serial.print("(T4) "); Serial.println(col3); // get value using T4
- Serial.print("(T5) "); Serial.println(col4); // get value using T5
- Serial.print("(T6) "); Serial.println(row1); // get value using T6
- Serial.print("(T7) "); Serial.println(row2); // get value using T7
- Serial.print("(T8) "); Serial.println(row3); // get value using T8
- Serial.print("(T9) "); Serial.println(row4); // get value using T9
- */
- }
- //---------------------------------------------------------
- void setup()
- {
- Serial.begin(115200);
- Serial.println("ESP32 Touch Test");
- }
- //---------------------------------------------------------
- void loop()
- {
- col1 = touchRead(T6);
- col2 = touchRead(T7);
- col3 = touchRead(T8);
- col4 = touchRead(T9);
- row1 = touchRead(T0);
- row2 = touchRead(T3);
- row3 = touchRead(T4);
- row4 = touchRead(T5);
- // printout();
- if ((col1 < THRESHOLD) && (row1 < THRESHOLD))
- { Serial.println("1"); printout();}
- if ((col1 < THRESHOLD) && (row2 < THRESHOLD))
- { Serial.println("2"); printout();}
- if ((col1 < THRESHOLD) && (row3 < THRESHOLD))
- { Serial.println("3"); printout();}
- if ((col1 < THRESHOLD) && (row4 < THRESHOLD))
- { Serial.println("A"); printout();}
- if ((col2 < THRESHOLD) && (row1 < THRESHOLD))
- { Serial.println("4"); printout();}
- if ((col2 < THRESHOLD) && (row2 < THRESHOLD))
- { Serial.println("5"); printout();}
- if ((col2 < THRESHOLD) && (row3 < THRESHOLD))
- { Serial.println("6"); printout();}
- if ((col2 < THRESHOLD) && (row4 < THRESHOLD))
- { Serial.println("B"); printout();}
- if ((col3 < THRESHOLD) && (row1 < THRESHOLD))
- { Serial.println("7"); printout();}
- if ((col3 < THRESHOLD) && (row2 < THRESHOLD))
- { Serial.println("8"); printout();}
- if ((col3 < THRESHOLD) && (row3 < THRESHOLD))
- { Serial.println("9"); printout();}
- if ((col3 < THRESHOLD) && (row4 < THRESHOLD))
- { Serial.println("C"); printout();}
- if ((col4 < THRESHOLD) && (row1 < THRESHOLD))
- { Serial.println("*"); printout();}
- if ((col4 < THRESHOLD) && (row2 < THRESHOLD))
- { Serial.println("0"); printout();}
- if ((col4 < THRESHOLD) && (row3 < THRESHOLD))
- { Serial.println("#"); printout();}
- if ((col4 < THRESHOLD) && (row4 < THRESHOLD))
- { Serial.println("D"); printout();}
- delay(10);
- }
Add Comment
Please, Sign In to add comment