Hi there, I'm using this code to save and load files from the microSD card, but instead of repeating this 33 times (one for each variable I need to save) would like to do in a loop, using an array
Save:
Load:
so I do an array for the names, to use fileName instead of "/VAL.DAT"
but no idea about how to do an array with the pointers of the variables I need to save & load,
and no idea how the code should be to use that array,
any advice would be much appreciated, thanks
Save:
Code:
String file = "/VAL.DAT";
if (SD.exists(file.c_str()))
{
SD.remove(file.c_str());
}
dataFile = SD.open(file.c_str(), FILE_WRITE);
dataFile.write((uint8_t *)&val, sizeof(val));
dataFile.close();
Code:
String file = "/VAL.DAT";
dataFile = SD.open(file.c_str(), FILE_READ);
dataFile.read((uint8_t *)&val, sizeof(val));
Code:
const String fileName[] = { "/VAL.DAT", "/PROB.DAT", "/STEPS.DAT" ...etc };
and no idea how the code should be to use that array,
any advice would be much appreciated, thanks