#define TOUCH_PIN 4 // Pino de toque (0 a 9 no ESP32)
#define BUZZER_PIN 5 // Pino do buzzer
int lastTouchValue = 0;
void setup() {
Serial.begin(115200);
pinMode(BUZZER_PIN, OUTPUT);
}
void loop() {
int touchValue = touchRead(TOUCH_PIN);
if (touchValue < 100 && lastTouchValue >= 100) {
// Se o toque for detectado, gera um som
tone(BUZZER_PIN, 1000, 500); // Frequência de 1000 Hz por 500 ms
}
lastTouchValue = touchValue;
}