In this guide we will going to make a simple Earth Quake monitoring device and learn how to connect and control the digital shock/vibration sensor module, we will going use the LED as our triggered output instead using alarm or any special output devices. When the sensor detects a vibration the LED will blink instead of sound alarm.
Electronic Parts Required
Required for Manual Circuit Assembly
- Arduino UNO/MEGA/PRO
- 1x Vibration Tilt Switch
- 1x LED
- 1x 220 k Resistor
- 1x 10k Resistor
Vibration Tilt Switch Module
Wiring the module
Switching Method
Source Code #1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
/* 14CORE.com / Simple Earthquake Detection using Vibration Sensor Module on Arduino. */ int OUTPUT_LED = 10; //Digital Pin 10 define LED interface int VIBRATION = 3; //Digital Pin 3 define vibration sensor interface int VAL; // Define the variable as VAL void setup() { pinMode(OUTPUT_LED,OUTPUT); //The defined Output as LED pinMode(VIBRATION,INPUT); //The defined input as Vibration } void loop() { VAL=digitalRead(VIBRATION); if(VAL==HIGH) // If the sensor detects a vibration digital pin 10 will be HIGH note! you can change whatever output you want { digitalWrite(OUTPUT_LED,LOW); //if detects no vibration LED stay in LOW } else { digitalWrite(OUTPUT_LED,HIGH); } } |
Source Code #2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
/* 14CORE TEST CODE */ int Din = 2; int Dout = 13; int LEDStatus = HIGH; int Reading; int Previous = LOW; long DTime = 0; long Dbounce = 50; void setup() { pinMode(Din, INPUT); digitalWrite(Din, HIGH); pinMode(Dout, OUTPUT); } void loop() { int ReadingState; Reading = digitalRead(Din); if(Reading != Previous) { DTime = millis(); } if ((millis() -DTime)>Dbounce){ ReadingState = Reading; if(ReadingState == HIGH) LEDStatus = LOW; else LEDStatus = HIGH; } digitalWrite(Dout, LEDStatus); Previous = Reading; } |
Simple Earthquake Detection Sensor with Vibration Module
May I have your ‘EEPROMAnything.h’ header?
You can use the EEPROM from the Arduino IDE
Reference > http://playground.arduino.cc/Code/EEPROMWriteAnything
Download the code library below.
https://github.com/arduino/Arduino/tree/master/hardware/arduino/avr/libraries/EEPROM