Introduction
This experiment demonstrates how to detect earthquake-like vibrations using a vibration sensor.
Components Needed
- Vibration Sensor
- Arduino
- Jumper Wires
Circuit Setup
- Connect the vibration sensor to the Arduino using digital pins for the signal.
The sensor detects vibrations and sends a signal to the Arduino whenever the threshold is exceeded.
Code for Vibration Detection
Upload the following code to your Arduino to detect vibrations:
const int sensorPin = 2; // Pin connected to the vibration sensor
int sensorValue;
void setup() {
pinMode(sensorPin, INPUT);
Serial.begin(9600);
}
void loop() {
sensorValue = digitalRead(sensorPin);
if (sensorValue == HIGH) {
Serial.println("Vibration Detected!");
}
delay(500);
}
Explanation
The vibration sensor detects any movement or vibrations and sends a high signal to the Arduino when motion is detected.
Troubleshooting
- If no vibrations are detected, check the sensor placement and sensitivity settings.
- Ensure the sensor is connected to the correct pin on the Arduino.