How you assing the serial port on the microcontroller

where in the arduino ide, the serial port pin for the microcontoller is assigned, I was looking on pins_arduino.c but I don't think is there.

I don't get what you just said. Do you want to know how to select the Serial port for the Arduino to download a sketch? Then click Tools > Serial Port > [portname]. On Windows, the port name should be something like "COM5". To check what port your Arduino is connected to (on Windows), go to Control Panel > System > Hardware > Device Manager > Ports (COM & LPT).

1 Like

On the Arduino (really the ATMega328P) the serial port uses Arduino pins 0 & 1. These are actually physical pins 2 & 3 on the 328.

The serial (specifically UART) pins are not defined by the software - they are defined by the hardware.

The chip has a "UART Peripheral" inside it - a section of the silicon which deals with serial communication. It is hard-wired to pins 2 & 3 of the Atmel chip and cannot be changed.

If you want to use other pins for serial communication, then you will have to use a software serial emulation layer, like SoftwareSerial, or NewSoftSerial (deprecated).

icemetal: where in the arduino ide, the serial port pin for the microcontoller is assigned, I was looking on pins_arduino.c but I don't think is there.

As others have mentioned, serial is done in hardware. So you will not find pin assignments in any of the Arduino core files. Instead, if you look at the Serial-source codes, you'll notice that references to the serial registers are used.