Serial communication is used for communication between the Arduino board and a computer or other devices. All Arduino boards have at least one serial interface (also known as UART or USART). It communicates with the computer via digital pins 0 (RX) and 1 (TX) and via USB. Therefore, when you use these functions, you cannot use pins 0 and 1 for digital input or output.
Serial Monitor in the Arduino IDE
You can use the built-in serial monitor of the Arduino environment to communicate with an Arduino board. Click the serial monitor button on the toolbar, and select the same baud rate that was used to call begin ().
Selecting which port to open in the serial monitor is the same as selecting a port to upload Arduino code. Go to Tools -> Serial Port and select the correct port.
The serial monitor has limited settings, but is sufficient to meet most serial communication needs. The first setting you can change is the baud rate. Click the baud rate drop-down menu to select the correct baud rate.
Serial ports
Serial communication on the TX / RX pins uses TTL logic levels (5 V or 3.3 V, depending on the board). Do not connect these pins directly to an RS232 serial port. They operate at +/- 12V and may damage your Arduino board.
+The Arduino Mega has three additional serial ports: Serial1 on pins 19 (RX) and 18 (TX), Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). To use these pins for communication with your PC, you will need an additional USB-to-serial adapter, since they are not connected to the Mega's USB-to-serial adapter. To use them to communicate with an external TTL serial device, connect the TX pin to your device's RX pin, the RX to your device's TX pin, and your Mega's ground to your device's ground.
The Arduino DUE has three additional 3.3 V TTL serial ports: Serial1 on pins 19 (RX) and 18 (TX); Serial2 on pins 17 (RX) and 16 (TX), Serial3 on pins 15 (RX) and 14 (TX). Pins 0 and 1 are also connected to the corresponding pins of the ATmega16U2 serial-to-USB-to-TTL chip, which is connected to the USB debug port. Additionally, there is a native serial USB port on the SAM3X chip, SerialUSB '.
The Arduino Leonardo uses Serial1 to communicate serially on pins 0 (RX) and 1 (TX) via TTL (5V). Serial is reserved for USB-CDC communication. More information can be found on the Leonardo start page and the hardware page.