I try the code like below ,
it makes a directory if it is not present on the SD cart , but it would not write the file into this directory
can somebody help me with this?
if(SD_OK)
{
int y = year()-2000;
char dir[5];
char fileName[20];
int fileCounter=0;
sprintf(dir,"%04d",year()); //directory naam : 2013/
if (!SD.exists(dir))
{
SD.mkdir(dir);
}
do
{
fileCounter++;
sprintf(fileName,"%02d%02d%02d_%01d.csv",y,month(),day(),fileCounter);
}
while (SD.exists((dir,fileName)) && fileCounter<9); //if file in directory exist and counter<9 generate new name
logFile = SD.open((dir,fileName), O_CREAT | O_WRITE); //open file in directory
You combine a dir and a filename.
But this "SD.exists((" and "SD.open((" have double parentheses, that is very weird. Are you used with another programming language ?
Please read how to use them:
You could make a buffer and use strcat() to create the full filename with path. You have to use a '/' between them. I checked my code, and I have something like this: "/ARDUINO/LOG.TXT"
Erdin:
You combine a dir and a filename.
But this "SD.exists((" and "SD.open((" have double parentheses, that is very weird. Are you used with another programming language ?
You could make a buffer and use strcat() to create the full filename with path. You have to use a '/' between them. I checked my code, and I have something like this: "/ARDUINO/LOG.TXT"
Thnx for help, i will look intro it
And no i am not commen, to programma anymore. I programmed 15years ago in c++. im try to learn the c code again