Vibration Sensor Arduino Alarm
Vibration sensor circuit uses a Piezoelectric sensor or PZT transducer. A piezoelectric sensor works with the piezoelectric effect, which is the ability of certain materials to generate an electric charge in response to the applied physical stress. The piezoelectric crystal converts physical parameters such as pressure, strain or force to a corresponding electrical charge.
In the circuit, the piezo sensor is connected across the Analog read pin A0 and the GND. If any vibration occurs, proportional rate of electrical potential induces across the piezo terminals.
The analog read pin compares the induced voltage with a reference value. If the voltage induced is greater than the reference threshold value the Alarm will ON. The alarm remains ON for 10 seconds after the triggering. Change the value of delay function to adjust the ON time of the alarm.
The speaker is connected to pin 9 on the arduino board. The tone function of the arduino is used to generate the alarm (arduino tone generator). An LED for the visual indication is added to the pin10.
The sensitivity of the device can be varied by adjusting the threshold value. The threshold should be set to an optimum value, which can ignore minute vibrations and at the same time it doesn’t need any heavy vibrations for triggering.
Vibration sensor arduino alarm Code
const int threshold = 50;
void setup() {
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
}
void loop() {
if (analogRead(A0) >= threshold) {
digitalWrite(10, HIGH);
tone(9, 600, 3000);
delay(10000);
digitalWrite(10, LOW);
}
}