Hello, teachers and friends,
I think Arduino is easy ,but difficult. I have a problem about the serial monitor.
I'd like to know how to continuously keep the first text line which describes the data into the serial monitor?
for example of serial monitor;
AX BX CX // first text line
0 0 0 // input data (1 data per 1sec)
1 1 1 // input data (1 data per 1sec)
2 2 2 // input data (1 data per 1sec)
0 0 0
1 2 3
1 3 2
But, as you know, the first text line will be disappeared in the serial monitor after about 30sec..
I want to see the first text line for data and the newest data at the same time.
In general, the source code as follows.
This is the example in the Arduino program.
void setup()
{
Serial.begin(9600);
while (!Serial) {
}
Serial.print("Initializing SD card...");
if (!SD.begin(chipSelect)) {
Serial.println("Card failed, or not present");
return;
}
Serial.println("card initialized.");
Serial.println("AX, BX, CX"); // first text line for data, how to continuously keep?
}
void loop()
{
String dataString = "";
for (int analogPin = 0; analogPin < 3; analogPin++) {
int sensor = analogRead(analogPin);
dataString += String(sensor);
if (analogPin < 2) {
dataString += ",";
}
}
File dataFile = SD.open("datalog.txt", FILE_WRITE);
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
Serial.println(dataString);
}
else {
Serial.println("error opening datalog.txt");
}
}
I'm very appreciate if you prompt reply.
Thank you in advance.