- 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
- 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;
- }
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: