Hi. Really needs some help here.
I have a 2D array in my SD card.
I need to retrieve it and print all values (float) on Serial Monitor.
Is there any way to do this?
Thank you.
Code:
#include <SPI.h>
#include <SD.h>
// change this to match your SD shield or module;
// Arduino Ethernet shield: pin 4
// Adafruit SD shields and modules: pin 10
// Sparkfun SD shield: pin 8
const int chipSelect = 4;
#define maxrow 11
#define maxcol 4
File dataFile = SD.open("testfile.txt");
void setup()
{
// Open serial communications and wait for port to open:
Serial.begin(9600);
while (!Serial) {
; // wait for serial port to connect. Needed for Leonardo only
}
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(SS, 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. note that only one file can be open at a time,
// so you have to close this one before opening another.
// if the file is available, write to it:
if (dataFile) {
while (dataFile.available()) {
Serial.print("File existed");
}
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening datalog.txt");
}
}
void loop()
{
for(int i=1; i<maxrow; i++)
{
for (int j=1; j<maxcol; j++)
{
int myArray[30][4]={dataFile};
Serial.println(myArray[i][j]);
}
}
}