I have an Arduino Uno and tried this originally with no answer or solution and thought it was a hardware problem. I now have a new Arduino Mega and it gives me the same problem. I've tried every single Baud Rate in code and in the serial monitor's drop down menu.
Why am I getting random ASCII characters? This is clearly a software problem, seeing as I tried this on over 2 Arduino boards. Do I have to change the USB settings on my laptop?
Thanks, and please help with this.. This has gone unanswered for too long. Most forums with this question have it randomly start working for no reason which doesn't help me find out why.
And if you do not put a delay in your loop it's going to execute the serial.println statement thousands of times every second which will result in totally unpredictable results.
MikMo:
And if you do not put a delay in your loop it's going to execute the serial.println statement thousands of times every second which will result in totally unpredictable results.
What will be unpredictable?
Irritating and repetitive, maybe, but not unpredictable.
Sorry, I wasn't home when I posted this question. The following code gives me an output of: "áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'áfr'á" endlessly with the serial monitor set to 14400 baud with newline. I tested other options in serial monitor drop down as well.
I uploaded the "demo" example to my Mega and the serial connection worked with 115200 baud rate! This makes no sense since I tried this earlier today with a barebones program like the following without success:
I tried it again now and it works. Although no other baud rates work still. For those telling me to deal with it or just use what works, this doesn't answer my question! Why could this possibly happen... All I did was drag-n-drop the library into my arduino folder and a new baud rate works.
It appears all the answers to these questions just "randomly work"..I don't accept this
Entirely predictable That's the sequence* you get when serial monitor is set at 9600 baud.
What is the baud rate you see when you open the serial monitor? 9600, 14400? The serial monitor can be overloaded by the stuff it receives from the Arduino, and your changes will be ignored. So, in your sketch try to set a delay such as 5000 - it will not overload the serial monitor and allow you to set the baud rate. Then change again the delay in the sketch to a smaller value and see what happens.
Try this. Press and hold down the reset button on your board. Now close the serial port. Recheck that you have the correct serial port number selected in the tools menu. Then reopen the serial monitor and make sure the baudrate shown in the lower right is correct or change it if it's not. Now release the reset button.
Let's review what should happen (look especially at the leds on the Arduino):
you disconnect the Arduino, so any message still waiting in the serial buffer is cleared.
you reconnect the Arduino and upload your sketch: the TX and RX leds on the Arduino blink for a while. Then after 10 seconds (5000 + 5000 in setup()) the TX led stays on.
you open the serial monitor: the Arduino resets, (TX led off) after 10 seconds the TX led starts to blink, once every 500 msecs you receive some garbage in the serial monitor, in sync with the blink. You read in the serial monitor that the baud rate is --- not what you have written in the sketch.
you change the baud rate in the serial monitor window to 14400: the Arduino resets, after 10 seconds the TX led starts to blink, once every 500 msecs you receive the "test" string.
Does anything different happen in your setting?
My first thought is that your operating system (which OS?) is somehow interfering with your ability to change the serial baud rate. My second thought is that your preferences file may interfere with your ability to change the serial baud rate (look in the preferences.txt file somewhere in your user directory, there should be an entry serial.debug_rate).
And it has 5 second delays before calling serial begin and after, as well as a half second delay between loops.. this is plenty
You actually never mentioned is this result directly copy pasted from the serial monitor (with the wrong rate), or are you trying to receive the data with some other device. I'm guessing the former. Naturally the receiver has to receive the data at the same rate the sender is operating at. Same goes with the serial monitor on Arduino IDE. Or maybe you are not even using the IDE, I can't tell.
you change the baud rate in the serial monitor window to 14400: the Arduino resets
Changing the baud rate in the serial monitor doesn't reset the Arduino. At least, that has not been my experience.
It does using IDE 1.0.3, just tested again using simple blink test that has no serial commands at all. Opening serial monitor resets the board and changing to any other baudrate also causes a reset.
Using windows XP SP3.
Lefty