Serial question

Could you please help on following comment ;

Serial.begin(9600); // what is 9600??

Thanks

nish1013:
Serial.begin(9600); // what is 9600??

Serial communications can happen at varying speeds. The 9600 baud means data will send/receive at 9600 bits per second. The higher the number the faster it goes but the more likely errors will happen or the other device your talking to will not go as fast.

Serial communications can happen at varying speeds. The 9600 baud means data will send/receive at 9600 bits per second. The higher the number the faster it goes but the more likely errors will happen or the other device your talking to will not go as fast.

Many thanks for this answer. I have seen almost every code sample have used 9600, any reason for choosing this speed?

I can only assume the reasoning for this stems from the early arduino's that used a computer serial port for connection instead of the more modern USB they now use. Also the slower speeds like this will be supported by more devices. I personally use 115200 baud as it works fine for me and one or two projects I have done needed fast data transfer and 115200 is the usual maximum a PC will go to though the arduino will go quite a bit faster still.

Whatever speed you set it to don't forget to set the Serial monitor or other serial device to the same baud rate or you will get gibberish. As to why 9600 is common, that is the default for the Serial monitor when it is installed, and I suspect that many people don't know or care that it can be changed.

Riva:

nish1013:
Serial.begin(9600); // what is 9600??

Serial communications can happen at varying speeds. The 9600 baud means data will send/receive at 9600 bits per second. The higher the number the faster it goes but the more likely errors will happen or the other device your talking to will not go as fast.

No no no!

Baud rate is not bit rate. Baud is in symbols-per-second, bitrate is in bits-per-second.

An RS-232 character is made of a number of data symbols, plus start and stop symbols and parity symbols. A typical format of 8-N-1 has 8 data symbols, 1 start, and 1 stop symbol, with no parity. That's 10 symbols (1's or 0's) sent in total for an 8 bit byte.

9600 baud, or 9600 symbols per second, is actually 9600 / 10 * 8 bits per second, or an "average baseband rate" of 7680 bits per second, or 960 characters per second.

majenko:
No no no!

Baud rate is not bit rate. Baud is in symbols-per-second, bitrate is in bits-per-second.

An RS-232 character is made of a number of data symbols, plus start and stop symbols and parity symbols. A typical format of 8-N-1 has 8 data symbols, 1 start, and 1 stop symbol, with no parity. That's 10 symbols (1's or 0's) sent in total for an 8 bit byte.

9600 baud, or 9600 symbols per second, is actually 9600 / 10 * 8 bits per second, or an "average baseband rate" of 7680 bits per second, or 960 characters per second.

Your splitting hairs, I did not say data bit's, just bits. It seemed pointless to add stuff like start, stop & parity for someone who did not know what the number meant.

The 9600 baud means data will send/receive at 9600 bits per second.

That says data bits to me... Saying that data sends at 9600 bits per second on a 9600 baud serial port is just wrong. It's not a case of splitting hairs, it's a simple plain fact. Data on a 9600 baud serial port at 8-N-1 sends at 7680 bits per second. Data and transmitted signal are two completely different things. The baud refers to the transmitted signal (hence the special name "baud" - they don't call it that just on a whim), not the data speed (called the baseband rate).