Go Down

Topic: How to write newline to sdfile? (Read 1 time) previous topic - next topic


Hi all,

i try to write sensor values to a line in a SD file, i use sdfatlib. It works OK.
But: i want to write a newline ("\n") every 5000 characters.

I thought of doing:

Code: [Select]

if (str.length() > 5000){

but it does not work very well. Which character should i use?


but it does not work very well. Which character should i use?

Ah, the famous "that didn't work" statement.

That code does something. You expect(ed) it to do something. What either thing is is not clear.

As a hint, though, the class you are using most likely derives from the Print class, this has both print() and println() methods. The println() methods do know how to place a carriage return AND line feed in the file.

Your call is adding one, but not the other, which, to some applications, makes a difference.
The art of getting good answers lies in asking good questions.

Tom Carpenter

If say you were using Windows, and say Notepad to view the files, you would need to declare the Carriage Return character aswell as windows uses <CR><LF> to move to a new line. You could try sdfile.print("\r\n").

Go Up

Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

via Egeo 16
Torino, 10131