私のデータはSDカードのテキストファイルにあり、Arduinoで配列にしようとしています。私のデータは、1 行に 270 個の数字が並んでいるように見える単なる整数の集まりです。
122
50
255
0
96
このような数字が 270 個あります。そのデータを使用できるように、Arduinoにサイズ270の配列を作成させたいだけです。後で、要素を引き出してどこかに配置します。与えられた例に従って、SD カードからデータを読み取ることができます。配列に作成するのに苦労しています。
これは私がこれまでに試したことです。私のコードでは、String3_5 が必要な配列は、0 から 269 までの数字を与えるだけです。
#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() {
}