 
   }
 
-  if (currentMillis - previousMillis3 >= time3)
+  if ((currentMillis - previousMillis3 >= time3) && (start == true) )
   {
     serial_data();
     previousMillis3 = currentMillis;  // Remember the time

  }

  //Serial.println("card initialized.");
  //char filename[16]; // make it long enough to hold your longest file name, plus a null terminator
  int n = 0;
  snprintf(filename, sizeof(filename), "data%03d.txt", n); // includes a three-digit sequence number in the file name

long time2 = 250;           // milliseconds of on-time

//SD
unsigned long previousMillis3 = 0;        // will store last time LED was updated
long time3 = 500;           // milliseconds of on-time

bool start = false;

//MPU6050
unsigned long previousMillis4 = 0;        // will store last time LED was updated
