 
   //Serial.print("freeMemory()=");
   //Serial.println(freeMemory());
-  
+  pinMode(9, INPUT);
 }
 bool saveDataToSD = true;
-bool doInterval = false;
+bool doInterval = true;
+bool doSleepInterval = false;
 
 unsigned long lastTime = 0;
+unsigned long sleepingTime = 0;
 
 void loop() {
   // put your main code here, to run repeatedly:
+  doSleepInterval = digitalRead(9);
   if(Serial.available() > 0){
     char input = Serial.read();
     bufferString+=input;

TinyGPSPlus gps;
SoftwareSerial softwareSerial(7, 8);

#include <MemoryFree.h>

//Compass
#define compassAddr 0x0D

  }
}

void goToSleep(){
  softwareSerial.end();
  Serial.println(F("Going to sleep mode..."));
  delay(40);
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);//   8Sec
  LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);// + 8Sec
  LowPower.powerDown(SLEEP_4S, ADC_OFF, BOD_OFF);// + 4Sec
                                                 // = 20Sec
  Serial.println(F("Woke up!"));
  softwareSerial.begin(9600);
}

