// Define the pin where the touch sensor is connected const int touchPin = 7; // GPIO pin const int ledPin1 = 4; // GPIO pin const int ledPin2 = 5; // GPIO pin void setup() { // Initialize serial communication at 115200 bits per second: Serial.begin(115200); // Configure the touch sensor pin as an input pinMode(touchPin, INPUT); // Configure the LED pins as outputs pinMode(ledPin1, OUTPUT); pinMode(ledPin2, OUTPUT); } void loop() { // Read the state of the touch sensor int touchState = digitalRead(touchPin); // Print the raw state to the serial monitor Serial.println(touchState); // Check if the sensor is touched if (touchState == HIGH) { // If the sensor is touched, print this message Serial.println("Sensor touched!"); // Turn on the LEDs digitalWrite(ledPin1, HIGH); digitalWrite(ledPin2, HIGH); } else { // If the sensor is not touched, print this message Serial.println("Sensor not touched."); // Turn off the LEDs digitalWrite(ledPin1, LOW); digitalWrite(ledPin2, LOW); } // Delay a bit to avoid spamming messages delay(500); }