I'm trying to clear a log file stored on a SD card. I first delete the file and then create a new one using SD open.
The new file appears in capitals (old filename was in lowercase). The easy way to solve this is only using files in capitals. Was wondering if i have another option.
I use an ethernetshield on an arduino mega.
My code:
#include <SD.h>
#include <SPI.h>
char DatFilC[11] = "log.csv";
const int chipSelect = 4;
void setup(){
Serial.begin(9600);
Serial.print(F("Initializing SD card... "));
if (!SD.begin(chipSelect)) {
Serial.println(F("Card failed, or not present"));
while(1){};
}
Serial.println(F("card initialized."));
}
void loop(){
//SD.remove(DatFilC);
File dataFile = SD.open(DatFilC, FILE_WRITE);
if (dataFile){
Serial.println();
Serial.print(F("File "));
Serial.print(DatFilC);
Serial.println(F(" is now empty."));
dataFile.close();
}
while (1){}
}