I am new to Arduino, and I am trying to understand the serial communications a little better. I have written some code that communicates serially to my Mac while the USB cord is connected, using commands like Serial.println(). In that regard, the serial communications is happening over the USB cord.
But I noticed that the GPIO pins 0 and 1 are described as RX and TX also. Is that a separate serial port from the one that is used over USB? Or is it the case that using those pins as a serial port disallows the use of serial communication over the USB cord?
I did see that there is a library called SoftwareSerial that allows for separate serial communicates over specified digital IO pins.
But my question is more specifically about whether the RX and TX of pins 0 and 1 is the somehow tied to the serial communications that happens over USB.
I am new to Arduino, and I am trying to understand the serial communications a little better. I have written some code that communicates serially to my Mac while the USB cord is connected, using commands like Serial.println(). In that regard, the serial communications is happening over the USB cord.
But I noticed that the GPIO pins 0 and 1 are described as RX and TX also. Is that a separate serial port from the one that is used over USB? Or is it the case that using those pins as a serial port disallows the use of serial communication over the USB cord?
I did see that there is a library called SoftwareSerial that allows for separate serial communicates over specified digital IO pins.
But my question is more specifically about whether the RX and TX of pins 0 and 1 is the somehow tied to the serial communications that happens over USB.
Thanks,
Dennis
On the UNO, there are two chips... the ATMEGA328p (the microcontroller) and an ATMEGA16U2 (USB to Serial interface).
The 328p RXD and TXD pins (pins 0 and 1 on the board) are the serial receive and transmit pins and they are connected to the 16U2 chip (the USB to Serial chip).
These pins are "active" only during bootloader operation (that is, when you are sending a new sketch to the board) OR when you have activated the serial port by using "Serial.begin (baud_rate);".
Otherwise, these pins are available to use like any other pins.
SOFTWARE serial allows you to use other pins for serial I/O, but I would advise against it since (at least in my experience) it's not very robust and seems to garble data as much as it transfers it.