int vibrationSensorPin = 2; // Define the pin where the vibration sensor is connected bool vibrationDetected = false; // Flag to track vibration detection status int count =0; // Setup function runs once when the Arduino board starts up or is reset void setup() { Serial.begin(9600); // Initialize serial communication for debugging pinMode(vibrationSensorPin, INPUT_PULLUP); // Set the vibration sensor pin as an input } // Loop function runs repeatedly as long as the Arduino board is powered on void loop() { // Read the digital state of the vibration sensor pin if (digitalRead(vibrationSensorPin) == LOW) { count++; Serial.print("Count ="); Serial.print(count); Serial.println(" Vibration detected, HIGH logic from SENSOR"); vibrationDetected = true; // Set the flag to indicate vibration detected delay(1000); // Wait for 1 second (1000 milliseconds) } else { if (vibrationDetected) { // If no vibration is detected, you can perform other actions here Serial.println("No vibration detected, LOW logic from SENSOR"); vibrationDetected = false; // Reset the flag } } }