Hello, I need to dynamically change the directory or file name in the SD.open() [ex. SD.open("/0/file.txt") ] function. I tried String typecasting into the function but I get an error. I need to dynamically change which directory I'm opening based on an externally inputted variable while the Arduino is running in the wild. For example, if the number I get in the wild is 1,2,3 I would need a way to do this SD.open(1/2/3); without having to hard code the "1/2/3" argument in the function.
I tried typecasting the variables as a String, char, and char* but none of these worked and produced errors. If you know of a way to dynamically change the directory on the fly then that would be very much appreciated!
Thanks, here's my code.
byte SD_CS = 4;
Serial.begin(9600); //open serial port
Serial.println("Initializing SD Card");
pinMode(SD_CS, OUTPUT); //CS for SD card
pinMode(10, OUTPUT); //CS must be an output for SPI to work
Serial.println("SD card initialization failed");
Serial.println("SD card ready");
test_file = SD.open(String(/0/test.txt), FILE_WRITE); //this line causes problems