i'm trying to save some values on a file stored in the SD card, the code is this one:
void loop()
{
// make a string for assembling the data to log:
String dataString = "";
int analogPin = 0;
for (int j=0; j<20; j++){
i=i+1;
int sensor = analogRead(analogPin);
dataString += String(sensor);
dataString += " ";
dataString += millis();
dataString += " ";
dataString += i;
dataString += "\n";
}
// open the file.
File dataFile = SD.open("rumore.txt", FILE_WRITE);
// if the file is available, write to it:
if (dataFile) {
dataFile.println(dataString);
dataFile.close();
// print to the serial port too:
Serial.println(dataString);
}
// if the file isn't open, pop up an error:
else {
Serial.println("error opening rumore.txt");
}
}
the problem is that it seems not to recognize this line: dataString += "\n"; so that while on the Serial monitor i get the right output,on the file rumore.txt values are not written in the same way, but they're all in the same line..any idea?