I would like to use an SDCard to store constants.
I am not sure how to implement this but would like to know if it is possible and/or recommended.
The type of constants that would be stored are unsigned int arrays i.e. (unsigned int Array1 = {1,10,100,1000,10000}
I am not sure if the arduino can load the array from the text file. Looking at SDCard breakout board sites (sparkFun.com and arduino.cc), it is possible to print the text file data to the serial port.
This is how would I implement this, but am very concerned if it would work for large arrays:
“datalog.txt” has a simple text array in it. i.e. 1,10,100,1000,10000,1,10,100,1000,10000;
#include <SD.h>
const int chipSelect = 10;
unsigned int Array1;
void setup()
{
Serial.begin(9600);
Serial.print("Initializing SD card...");
// make sure that the default chip select pin is set to
// output, even if you don't use it:
pinMode(chipSelect, OUTPUT);
// see if the card is present and can be initialized:
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
// don't do anything more:
return;
}
Serial.println("card initialized.");
// open the file
File dataFile = SD.open("datalog.txt");
// if the file is available
if (dataFile) {
for(int i = 0; dataFile.available(); i++) {
Array1[i] = dataFile.read(); // data saved to array
Serial.println(Array1[i]); // data printed to serial port to see data that was saved
}
dataFile.close(); // closed the SDCard file
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening datalog.txt");
}
}
void loop()
{
}