Hi all. I'm fairly new here so I'm still learning and I hope someone can help me, please!
I need to read sets of 5 integer variables one line at a time from a CSV file stored on an SD card. I have got the SD card working and I can read the file one line at a time. For example, if the data file is as below:
10,15,23,108,65
15,86,97,54,180
178,65,107,65,10
etc.
I can read each line individually (10,15,23,108,65 then 15,86,97,54,180 etc.)
My problem is that I can't figure out how to split the lines (strings) into integer values where the first integer is before the first comma, the second integer is between the first and second comma etc.
My code extract looks like this at the moment:
while (myFile.available()) {
char in_char = myFile.read();
inData += in_char;
if (in_char == '\n')
{
Serial.print("Arduino Received: ");
Serial.println(inData);
//
// this is where I need to split inData into the five integer values
// and then do something with each individually
//
inData = ""; // Clear received buffer
}
}
What am I missing, please? Or is there a better way to do this?
Thanks.
Richard