Line Wrap in Serial Monitor

I've got a program that grabs tweets and prints them in the serial monitor, but often I have to scroll to see the entire quote. Is there a way to tell the Arduino (I have an Uno R3) to wrap the text after a certain number of characters?

If you want the output to wrap onto a newline you need to print a new line character. The println() method conveniently appends a line feed to the output as it prints it, or you could include the \n line feed character in the string that you print.

The serial monitor in the Arduino IDE is pretty awful. Consider using Putty or another terminal emulator with better functionality -- such as wrapping.

The serial monitor in the Arduino IDE is pretty awful.

I rather like it, in that it forces people to think!

Maybe. I find it frustrating because it lacks the ability to log to a file. It is also frustrating for times when a sketch's output is very verbose, because it attempts to remember EVERYTHING, even between re-uploading sketches. So it can fill up with cruft that is very difficult to sift through -- where does the 22,312 lines of output from the previous version of the sketch end and the 112,344 lines from current one begin? Its performance suffers with millions of lines of crap in it, making it unresponsive, and there's no "clear buffer" function. It is basically crappy for what one needs it to do to monitor debug telemetry from a sketch. Its only saving grace is that the IDE automatically manages it.

If forcing me to think is the idea, then what's with the goofy "wiring" language in the first place? It's 99.95% C/C++ with just enough preprocessing to obscure that fact. I mean, either you want training wheels or you don't.

How would I add the newline command into a tweet?

How would I add the newline command into a tweet?

There is not a "newline command". There is a newline character (\n). Why you want that in the tweet, I don't know.

where does the 22,312 lines of output from the previous version of the sketch end and the 112,344 lines from current one begin?

I'd say that that much serial output is a clear indication that a modular development methodology was not followed. Each function should be testable on it's own, and should be thoroughly tested in a small sketch, before being added to a larger sketch.

PaulS:

How would I add the newline command into a tweet?

There is not a "newline command". There is a newline character (\n). Why you want that in the tweet, I don't know.

I need the tweet to fit in the serial monitor, starting a new line if necessary.

I need the tweet to fit in the serial monitor

Why? The Serial Monitor is not going to tweet for you.

Dawmasta:
How would I add the newline command into a tweet?

Break the tweet into sections.

Serial.print(first_section);
Serial.println();
Serial.print(second_section);
Serial.println();
Serial.println(third_section_section);

If you want the section breaks to be in fairly sensible places you need to ensure that they occur at a space in the tweet.

Break the tweet into sections.

Or, put a \n in the tweet, as has been mentioned.

It's not reading MY tweets (I don't even have a Twitter...), it's reading from another person's feed.

Dawmasta:
It's not reading MY tweets (I don't even have a Twitter...), it's reading from another person's feed.

In that case you just need to keep a record of the number of characters you have printed since the last linefeed, and insert a linefeed if it exceeds your maximum permitted line length.

So is there a way to set a variable equal to the current number of characters?

Dawmasta:
So is there a way to set a variable equal to the current number of characters?

int length = strlen(someNullTerminatedCharArray);

Dawmasta:
So is there a way to set a variable equal to the current number of characters?

Start the variable at 1 and increment it for each character that you output. This implies that you need to print strings (and do any formatting necessary to generate those strings yourself) rather than passing numbers etc to the Serial.print routines and letting the Serial object format them for you.

Set the variable back down to zero if you print a linefeed.