Hello,
I am kinda new with Arduino, but I try for a project to open different filenames from a sd-card with some data in this .txt. When I unplug the sd-card and put new .txt files on it, I want to open the files behind each other with a delay.
I use a Arduino Uno with a SD-Card-Module.
As File Example:
File 1: text.txt
File 2: number.txt
I tried to put the filename in a string and then open it, but this doesnt work.
Code:
File root = SD.open("/"); //open sd card
File file = root.openNextFile(); //first/next file
char filename[]= file.name(); //file name to string (dont work, put in println it is working?)
File currentfile = SD.open(filename); //variable to work with
if (currentfile) {
Serial.println("content:");
// reading file
while (currentfile.available()) {
Serial.write(currentfile.read());
}
// open file
Serial.println("\n");
currentfile.close();
} else {
// if the file didn't open
Serial.println("error opening file");
}
in SD.open() must be the filename with "", I want there the current/next filename from the sd-card.
Greetings.