I have an arduino mega conected to an SD card reader (catalex branded), that at least detect the card as it Displays the info of the card, but when i am trying to create a file, it does not create it, i am using the following code:
if (SD.exists("data.txt")) {
Serial.println("data.txt exists.");
} else {
Serial.println("data.txt doesn't exist.");
}
File root=SD.open("data.txt", FILE_WRITE); //open of the File for writting
if (SD.exists("data.txt")) {
Serial.println("data.txt exists.");
} else {
Serial.println("data.txt doesn't exist.");
}
i also tried with this code:
File root2 = SD.open("file.txt", O_RDWR | O_APPEND);
if (!root2) {
// It failed, so try and make a new file.
root2 = SD.open("file.txt", O_RDWR | O_CREAT);
if (!root2) {
// It failed too, so give up.
Serial.println("Failed to open file.txt");
}
}