i am working on project for touch sensor and vibration motor coin type.
where i have connected touch sensor to esp32 and vibration motor to esp32 .
when i touch sensor motor should vibrate, if not touched it should not vibrate but in my case without touch it is vibrating with less intensity but with touch it is vibrating with high intensity.
i have upload wiring and code, check if i have make any changes in it
#define TOUCH_SENSOR_PIN 5 // Touch sensor connected to GPIO5
#define MOTOR_PIN 13 // Vibration motor connected to GPIO13
void setup() {
Serial.begin(115200);
delay(2000); // Allow time for Serial Monitor to connect
Serial.println("ESP32 Touch Sensor with Vibration Motor");
// Set the touch sensor pin to input with an internal pull-up resistor
pinMode(TOUCH_SENSOR_PIN, INPUT_PULLUP);
// Set the motor pin to output
pinMode(MOTOR_PIN, OUTPUT);
digitalWrite(MOTOR_PIN, LOW); // Initially, motor is off
}
void loop() {
// Check if the touch sensor is activated (touched)
if (digitalRead(TOUCH_SENSOR_PIN) == LOW) { // Sensor triggered (LOW when touched)
Serial.println("Touch detected! Motor ON");
digitalWrite(MOTOR_PIN, HIGH); // Turn on the vibration motor
} else {
Serial.println("No touch detected. Motor OFF");
digitalWrite(MOTOR_PIN, LOW); // Turn off the vibration motor
}
delay(100); // Small delay for stability
}


