Pages: [1]   Go Down
Author Topic: Arduino Nano isn't working well with Baud rate 9600 bps, why?  (Read 913 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

This is a newbie question.
I connect my Arduino nano with PC using USB. The following sketch is tested:
int out = 3;
void setup() {     
  Serial.begin(9600);
}
void loop() {
println(out);
}

I clicked the Serial Monitor button of Arduino 1.0 IDE to watch the results.
Why did it display gibberish when the Baud rate 9600 was chosen in the Serial Monitor ?
However, it displayed right when the rate 19200 was chosen. Obviously this setting was inconsistent with the Baud rate in the above sketch. Weird.
Anyone can help? Thank you!
Logged

Offline Offline
Edison Member
*
Karma: 48
Posts: 1633
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Your code worked on my Nano after I changed println(out) to Serial.println(out).

Pete
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Actually my code is Serial.print(out). Sorry for the typos when posting it.
I just checked again. It still wasn't working.
Did you check the serial monitor of your Arduino IDE with different baud rate? Why mine is outputting gibberish with 9600.
Logged

Offline Offline
Edison Member
*
Karma: 48
Posts: 1633
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

It works fine at 9600 and outputs junk at 19200

Pete
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

When I use Serial.begin(9600), the serial monitor of Arduino outputs junk at 9600 and works fine at 19200;
When I use Serial.begin(19200), the serial monitor outputs junk at both 19200 and 9600.
I don't why it could happen.
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18810
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Looks like your Nano is running at 8 MHz. That would account for why you need to double the baud rate (from 9600 to 19200) to get 9600 actually being sent.
Logged


Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Nick, I think it might be the opposite.  That is, the board is probably running at 16 MHz but the code is being compiled for 8 MHz.  So when you say Serial.begin(9600), you're actually getting 19200 baud. 

bigthunder, are you sure you have the right item selected in the boards menu?
Logged

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 485
Posts: 18810
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Good point. I didn't think the arithmetic through enough. What you suggest is probably right, that the wrong board is selected in the menu, and the sketch is compiled with the wrong constants for the serial port, however the bootloader happens to match.
Logged


Offline Offline
Newbie
*
Karma: 0
Posts: 9
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thank you so much.
I made the mistake. I used the board Arduino Fio which I had set before. Now it's working perfect. Some coincidence did happen by this mistake.
Logged

Pages: [1]   Go Up
Jump to: