 }
 
 void setTravelTime() {
+    Serial.println("set travel time in sec");
     while (Serial.available() == 0) { }
     
     int input = Serial.parseInt();
     travelTime = input;
+    setLogInterval();
+}
+
+void setLogInterval() {
+    logInterval = (travelTime * 1000) / maxLogs;
+    logData = true;
 }
 
 void readDHT11() {
     int chk = DHT11.read();
-    switch (chk) {
-        case 0: Serial.println("OK"); break;
-        case -1: Serial.println("Checksum error"); break;
-        case -2: Serial.println("Time out error"); break;
-        default: Serial.println("Unknown error"); break;
-     }
+//    switch (chk) {
+//        case 0: Serial.println("OK"); break;
+//        case -1: Serial.println("Checksum error"); break;
+//        case -2: Serial.println("Time out error"); break;
+//        default: Serial.println("Unknown error"); break;
+//     }
     
 //      Serial.print("Humidity (%): ");
 //      Serial.println((int) DHT11.humidity, DEC);


// Variables to use for the interval
unsigned long previousMillis = 0;
long logInterval = 0; // Hoe vaak willen we loggen?

// Variables
dht11 DHT11;
DB db;
int travelTime = 0; // Total travel time in s
String msg;
boolean logData = true;
struct MyRec {
  int humidity;
  double temperature;
} myrec;

void setup() {
  // Initialize pins
  pinMode(ledPin, OUTPUT);
  
  logInterval = 2000;
  
  DHT11.attach(dht11Pin);
  Serial.begin(9600);
  
  db.create(TABLE, sizeof(myrec));
  db.open(TABLE);
}

void loop() {
   // put your main code here, to run repeatedly:
   while (Serial.available() > 0) {
     char recieved = Serial.read();
     msg += recieved;
     
     if (msg == "viewData") selectAll();
     else if (msg == "stopLogging") logData = false;
     else if (msg == "setTravelTime") setTravelTime();
   }
  
   unsigned long currentMillis = millis();
  

      
      readDHT11();
   }
}

void selectAll() {
