Go Down

Topic: new line (Read 758 times) previous topic - next topic

Yamat0

Im trying to write a String into a file on a SDcard. Each time i write to it it starts on a new line, but i would like to be able to tell when I want a new line to make the data a little bit more readable. Tabs would be nice too.
\n does not work, but it does not show up in the file ider..

any suggestions?

robtillaart

Quote
any suggestions?

Post your code so we can see what you tried.
(preferably minimize the sketch that shows this behaviour)

Did you use the somefile.println(); statement? It places a newline in the file.
Rob Tillaart

Nederlandse sectie - http://arduino.cc/forum/index.php/board,77.0.html -
(Please do not PM for private consultancy)

Yamat0

well, yes and no.

i collect alot of data during some seconds, then put it all with one write to the SDcard to save time(i guess?)

so i have something like this that i want to put into the .txt file and i want it to show the new lines.

String saveThisString="Data:\nvalue1=15\nvalue2=16\nvalue3=4"

with the  somefile.println(); i will get a linefeed only after the howl row is inserted. when i check the textfile i cant see the \n in the file, so the textfile has recogniced them as commands atleast.

i have a computer with swedish on it, if that makes any difference? in old basic you could add a chr(50) to get a linefeed within a text.

I want to save everything to this file as there will be hundreds of datas read, and I feel that opening and closing the SD card that many times seems like a bad idea.


fat16lib

Newline for Windows is "\r\n" also know as CR/LF.

The Arduino println() function appends "\r\n" for newline. 

Try changing your string like this:

Code: [Select]

  String saveThisString="Data:\r\nvalue1=15\r\nvalue2=16\r\nvalue3=4"

Yamat0

Thank you ! \r\n solved my problem! my output file is now readable!




Go Up