My data is in a text file in an SD card, and I am trying to make it an array in Arduino. My data is just a bunch of integers that will look like 270 numbers each one on a line.
122
50
255
0
96
I have 270 numbers like this. I just want Arduino to create an array of size 270 so I can use that data. Later on, I am going to pull out an element to put it somewhere, and so on. Following the example given I can read the data from the SD card. I'm having a hard time creating it into an array.
This is what I have tried so far. In my code the array I want String3_5 just gives me numbers 0 to 269 incrementing.
#include <SD.h>
const int chipSelect = 4;
int String3_5 [270];
int index = 0;
void setup() {
Serial.begin(9600);
Serial.print("Initializing SD Card....");
if(!SD.begin(chipSelect)) {
Serial.println("Card failed, or not Present");
return;
}
Serial.println("Card Initialized");
File dataFile = SD.open("Strip3_5.txt");
if(dataFile) {
while(dataFile.available()) {
Serial.write(dataFile.read());
String3_5[index] = Serial.read();
index++;
String3_5[index] = '\0';
}
dataFile.close();
} else {
Serial.println("File does not exist or named wrong");
}
}
void loop() {
}