/*const int touchPin0 = 4;
const int touchThreshold = 40; // Sensor threshold
void setup() {
Serial.begin(115200);
delay(1000); // Delay to launch the serial monitor
Serial.println("ESP32 - Touch Threshold Demo");
pinMode(touchPin0, INPUT);
}
void loop() {
int touch0raw = touchRead(touchPin0); // perform the reading
if(touch0raw < touchThreshold )
{
Serial.println("Touch detected");
}
delay(500);
}*/
int pinTactil = 4; // Pin táctil conectado al ESP32
int pinLED = 2; // Pin del LED conectado al ESP32
int valorTactil;
void setup() {
pinMode(pinTactil, INPUT);
pinMode(pinLED, OUTPUT);
}
void loop() {
valorTactil = touch_pad_t(pinTactil);
if (valorTactil < 50) { // Puedes ajustar este umbral según tu configuración
digitalWrite(pinLED, HIGH); // Enciende el LED si se toca la entrada táctil
} else {
digitalWrite(pinLED, LOW); // Apaga el LED si no se toca la entrada táctil
}
}Loading
esp32-c6-devkitc-1
esp32-c6-devkitc-1