Okay so I'll start off by saying I'm using a Arduino Uno with an Adafruit Datalogger Shield. Right now it makes one file called datalog.txt and it writes to it. Well the problem is, I need it to make a new file for every series of data. So it will turn on, record the data to a .txt file and then be turned of when the test is over. Then when it is booted back up again it needs to make a new file. Here is my code for the SD card in it's current state (What would be really nice is if someone could tell me a simple edit to my current code so I could fix this as painless as possible without having to completely rewrite my code) :
//Calling upon file for the clock
#include <Wire.h>
#include "RTClib.h"
RTC_DS1307 rtc;
File dataFile;
void setup(void) {
Serial.begin (9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(10, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
while (1) ;
}
Serial.println("card initialized.");
// Open up the file we're going to log to!
dataFile = SD.open("datalog.txt", FILE_WRITE);
if (! dataFile) {
Serial.println("error opening datalog.txt");
// Wait forever since we cant write data
while (1) ;
}
pinMode(7,INPUT); // This is the analog comparator negative input.
// This is where the input signal enters the Arduino.
SREG = SREG | B10000000; // Enable gobal interrupts. They should
// already be enabled but I like to do this out of good measure.
//Serial.begin(9600); // For printing the frequency to the terminal
SD.begin();
#ifdef AVR
Wire.begin();
#else
Wire1.begin(); // Shield I2C pins connect to alt I2C bus on Arduino Due
#endif
rtc.begin();
if (! rtc.isrunning())
{
Serial.println("RTC is NOT running!");
}
}