Simple Earthquake Sensor Detection And Vibration Mode By Arduino Mega 2560

Introduction

In my last article I explained about finding weather conditions using Arduino Mega 2560. Now In this article I will explain about simple earthquake sensor detection and vibration mode with Arduino Mega 2560.

Parts Of Lists
  • Arduino UNO/MEGA/PRO
  • 1x Vibration Tilt Switch
  • 1x LED
  • 1x 220 k Resistor
  • 1x 10k Resistor.
Connection

Connection from the Vibration Tilt Switch to Arduino Mega 2560:
Figure 1: Vibration Tilt Switch
  • Sensor Board
  • Vcc------->5V.
  • Gnd------->Gnd.
  • Din-------->02.
  • Connection From Led To ArduinoMega2560:
  • Postive pin(Dout)-------->13
  • Negative pin------->Gnd.
Programming
  1. int Din = 2;  
  2. int Dout = 13;  
  3. int LEDStatus = HIGH;  
  4. int Reading;  
  5. int Previous = LOW;  
  6. long DTime = 0;  
  7. long Dbounce = 50;  
  8. void setup()  
  9. {  
  10.     pinMode(Din, INPUT);  
  11.     digitalWrite(Din, HIGH);  
  12.     pinMode(Dout, OUTPUT);  
  13. }  
  14. void loop()  
  15. {  
  16.     int ReadingState;  
  17.     Reading = digitalRead(Din);  
  18.     if (Reading != Previous)  
  19.     {  
  20.         DTime = millis();  
  21.     }  
  22.     if ((millis() - DTime) > Dbounce)  
  23.     {  
  24.         ReadingState = Reading;  
  25.         if (ReadingState == HIGH) LEDStatus = LOW;  
  26.         else LEDStatus = HIGH;  
  27.     }  
  28.     digitalWrite(Dout, LEDStatus);  
  29.     Previous = Reading;  
  30. }  
Explanation

It will explain the earth level where we have fix.

When earthquake occurs, LED will ON.

When it does not occur, LED will OFF.

Output

                          Figure 2
 
Read more articles on Arduino:

Up Next
    Ebook Download
    View all
    Learn
    View all