New Line in a Text file

Hey,

I was just wondering how you would make it so when logging data it doesn't save all the data on one line, but instead its put on a new line each new entry, like hitting enter/return every time? currently it displays it like this:

"2016/12/12 15:30 55.77V"2016/12/12 15:30 55.77V"2016/12/12 15:30 55.77V"2016/12/12 15:30 55.77V"2016/12/12 15:30 55.77V"2016/12/12 15:30 55.77V

I don't know how to get it to this:

"2016/12/12 15:30 55.77V
"2016/12/12 15:30 55.77V
"2016/12/12 15:30 55.77V
"2016/12/12 15:30 55.77V
"2016/12/12 15:30 55.77V
"2016/12/12 15:30 55.77V

  logfile.print('"');
  logfile.print(now.year(), DEC);
  logfile.print("/");
  logfile.print(now.month(), DEC);
  logfile.print("/");
  logfile.print(now.day(), DEC);
  logfile.print(" ");
  logfile.print(now.hour(), DEC);
  logfile.print(":");
  logfile.print(now.minute(), DEC);
  logfile.print("   ");
  logfile.print(voltage * 11.132, 2);
  logfile.print("V");

The new line control character is \n. You can insert it at the place where you want to have a new line. You can also try to use .println() instead.

oh awesome, didn't know that

Thanks heaps :slight_smile:

The '\n' are two characters but they are treating like one. You can google for other control characters (or escape sequences) in C for your information like \r, ", \ ...

EDIT: Sorry, search for escape sequences, it is better.

You could also investigate the differences between the print() and println() methods.