diff --git a/earthquake/earthquake.ino b/earthquake/earthquake.ino
index 8e4f1151d21adf16ea49a8d83493b563ab458f94..fe839490d3e776ad1da087991e146513ac67dbe6 100644
--- a/earthquake/earthquake.ino
+++ b/earthquake/earthquake.ino
@@ -24,7 +24,7 @@ MPU6050 mpu;
 #define INTERRUPT_PIN 2  // use pin 2 on Arduino Uno & most boards
 #define LED_PIN 13 // (Arduino is 13, Teensy is 11, Teensy++ is 6)
 #define WAVE_TIMEOUT 100
-#define TIME_WAVE_STORE 500
+#define TIME_WAVE_STORE 100
 int waveDuration = 0;
 bool blinkState = false;
 // MPU control/status vars
@@ -44,6 +44,8 @@ VectorFloat gravity;    // [x, y, z]            gravity vector
 float euler[3];         // [psi, theta, phi]    Euler angle container
 float ypr[3];           // [yaw, pitch, roll]   yaw/pitch/roll container and gravity vector
 bool isChangeStore[TIME_WAVE_STORE];
+int periode;
+int frequency;
 //INTERRUPT DETECTION ROUTINE
 volatile bool mpuInterrupt = false;     // indicates whether MPU interrupt pin has gone high
 void dmpDataReady() {
@@ -59,6 +61,8 @@ void setup() {
 
   lastSeismoDetected = -10000;
   loopNumber = 0;
+  periode = 0;
+  frequency = 0;
 
   //LCD
   lcd.begin(16, 2);
@@ -129,7 +133,7 @@ void setup() {
 }
 
 void changeShift() {
-  int offset = 100;
+  int offset = 200;
   int dx = abs(aaWorldPrev.x - aaWorld.x);
   int dy = abs(aaWorldPrev.y - aaWorld.y);
   int dz = abs(aaWorldPrev.z - aaWorld.z);
@@ -146,10 +150,21 @@ void changeShift() {
 
 bool isChange(){
   int i;
-  for(i = 0; i < TIME_WAVE_STORE; i++){
+  int first = -1;
+  int second = -1;
+  for(i = TIME_WAVE_STORE-1; i >= 0 ; i--){
     if(isChangeStore[i]){
-      waveDuration = i;
-      return true;
+      if(periode!=0) return true;
+      if(first<0){
+        first = i;
+        continue;
+      }
+      if(second<0){
+        second = i;
+        periode = (first - second)*2;
+        frequency = 1*1000/periode;
+        return true;
+      }
     }
   }
   return false;
@@ -252,7 +267,11 @@ void loop() {
     bool check = isChange();
     digitalWrite(LED_PIN, check);
     if(check){
-      Serial.println(waveDuration);
+      Serial.println(periode);
+      Serial.println(frequency);
+    } else {
+      periode = 0;
+      frequency = 0;
     }
 //    if (check) {
 //      waveDuration = WAVE_TIMEOUT;