   }
 }
 
+// Log time to file
+void logTimeToFile(char* filename)
+{
+  // open the file. note that only one file can be open at a time,
+  // so you have to close this one before opening another.
+  myFile = SD.open(filename, FILE_WRITE);
+  
+  // if the file opened okay, write to it:
+  if (myFile) {
+    // Serial info
+    Serial.print("Writing '");
+    Serial.print(month());
+    Serial.print(" ");
+    Serial.print(day());
+    Serial.print(" ");
+    Serial.print(hour());
+    Serial.print(" ");
+    Serial.print(minute());
+    Serial.print("' to ");
+    Serial.print(filename);
+    Serial.print("... ");
+    
+    // Write value to file and close
+    myFile.print(month());
+    myFile.print(" ");
+    myFile.print(day());
+    myFile.print(" ");
+    myFile.print(hour());
+    myFile.print(" ");
+    myFile.print(minute());
+    myFile.close();
+    
+    Serial.println("done.");
+  } else {
+    // if the file didn't open, print an error:
+    Serial.println("error opening for writing.");
+  }
+}
+
 boolean startSD()
 {
   Serial.print("Initializing SD card...");

  buttonPressed = true;
}

void doButtonCall()
{
  delay(250);
  Serial.println("Woo");


void setup()
{
  Serial.begin(9600);
  setSyncProvider(RTC.get); // get time from Real Time Clock
  if(timeStatus()!= timeSet)
    Serial.println("Unable to sync with the RTC");
  else
    Serial.println("RTC has set the system time");

  // Set button to write to file
  attachInterrupt(0, buttonInterrupt, RISING);

  // Set call to update files every minute
  Alarm.timerRepeat(10, recordData);
}

void loop()
{
  if (buttonPressed)
  {
    recordData();
  }

  Alarm.delay(1000); // Check every second
}


