Serial Monitor: garbish in output

Hi Arduino Geeks,

Each time I open the serial monitor I get some "garbish characters" displayed ...

void setup() { Serial.begin(9600); Serial.print("Controller up and running."); Serial.print("\n"); inputString.reserve(254); }

The output looks like this ... @h½¹up and running. Setup 0: all off

@h½¹Ñɽ±±?Ɂup and running. Setup 0: all off

Anny hints how to prevent this ...?

thx Alexander

Which Arduino are you using?

Hi,

sorry for not mentioning: Arduino Mega 2560

Are there differences in serial behavior?

thx Alexander

You haven't posted all of your code.

I wonder if inputString.reserve(254); is corrupting something?

I guess you are using Strings (large S) which often cause problems in the limited memory of an Arduino. The general advice is to use strings (small s).

...R

ademmler: Hi,

sorry for not mentioning: Arduino Mega 2560

Are there differences in serial behavior?

thx Alexander

Not that one. I don't have a Leonardo but I recall some wait-around with serial for those.

Another thing to check is serial monitor has the same speed (baud rate).

I sometimes get some screen trash on starting serial monitor but I can't remember any fix. It usually precedes what my program sends. So yes, I am interested too!

Hello robin2,

thx for your hints. From your post:

I wonder if inputString.reserve(254); is corrupting something? I removed this option - the effect was the same. I use it because I use Serial Event: http://arduino.cc/en/Tutorial/SerialEvent

I guess you are using Strings (large S) which often cause problems in the limited memory of an Arduino. The general advice is to use strings (small s).

This I do not understand at all ... sorry. What does it mean. Greetings Alexander

Hi folks,

I found a solution by myself. This did the trick: //Setup Serial input and reserve 200 bytes for the inputString: Serial.begin(9600); inputString.reserve(200);

Serial.read(); inputString = "";

I have placed it at the top of setup. Alexander

I use it because I use Serial Event: http://arduino.cc/en/Tutorial/SerialEvent

Nonsense. The two are completely unrelated.

The advice to quit relying on the poorly implemented String class was sound. Heed it or you will see more problems.