Vibration Sensor Tutorial

Vibration Measurement with Vibration Sensor

Objective

This experiment shows how to measure vibration using a vibration sensor, which detects changes in the environment caused by vibrations.

Required Components

Working Principle

The vibration sensor consists of a piezoelectric element that generates an electrical signal when it detects vibration. The signal can be read and processed by the Arduino.

Circuit Diagram

Vibration Sensor Circuit Diagram

Follow these steps to wire the vibration sensor:

Arduino Code


/*
 * Vibration Measurement with Vibration Sensor
 * This code reads the vibration sensor output and displays it on the serial monitor
 */

const int vibrationPin = 2;  // Vibration sensor connected to digital pin 2
int vibrationState = 0;

void setup() {
    Serial.begin(9600);  // Initialize serial communication
    pinMode(vibrationPin, INPUT);  // Set the vibration sensor pin as input
}

void loop() {
    // Read the vibration state (HIGH or LOW)
    vibrationState = digitalRead(vibrationPin);

    // Print the vibration state to the serial monitor
    if (vibrationState == HIGH) {
        Serial.println("Vibration Detected!");
    } else {
        Serial.println("No Vibration.");
    }

    delay(500);  // Wait for 0.5 seconds
}
            

Results

Once the code is uploaded, the serial monitor will display "Vibration Detected!" when the sensor detects any vibrations, or "No Vibration" when the sensor is idle.

Applications

Conclusion

The vibration sensor is an effective tool for detecting vibrations, with applications in earthquake detection, security systems, and machinery monitoring.