Sub topic 7
Selecting the serial port
This chapter assumes you have installed the Arduino IDE, connected a board over USB with a data cable, and chosen your board under Tools > Board. Here you pick the serial port, the last setting the IDE needs before it can upload. It also covers what a port is, how the operating system names it, and what to check when the list is empty or wrong.
What a serial port is in this context
The IDE sends your compiled program to the board over USB. The operating system does not give programs direct access to the USB hardware. It exposes the connection as a serial port, a named channel that behaves like an old RS-232 line. The IDE opens that channel, talks to the board's bootloader or upload chip, and writes the program into flash memory.
On an Uno-class board, a chip on the board (an ATmega16U2, or on older boards a CH340 or FTDI chip) turns USB traffic into the UART signals the main microcontroller understands. The computer sees this chip as a "virtual COM port". Boards with native USB, such as the Leonardo, Micro, and many ARM-based boards, have no separate converter. The main chip presents the port itself.
The port is a property of the connection between your computer and one board. The board selection tells the IDE what to compile for. The port tells it where to send the result. Choosing the right board and the wrong port still fails.
How each operating system names ports
The names differ by platform. Knowing the pattern helps you pick the right entry when several are listed.
| Operating system | Typical name | Notes |
|---|---|---|
| Windows | `COM3`, `COM4`, and so on | `COM1` is usually a built-in port, so Arduino boards tend to appear as `COM3` or higher. |
| macOS | `/dev/cu.usbmodem14101`, `/dev/cu.usbserial-1410` | `usbmodem` is common for boards with a 16U2 or native USB. `usbserial` is common for CH340 and FTDI chips. |
| Linux | `/dev/ttyACM0`, `/dev/ttyUSB0` | `ttyACM` is common for native USB and 16U2 boards. `ttyUSB` is common for CH340, CP210x, and FTDI chips. |
On macOS you may also see /dev/tty. entries next to the /dev/cu. ones. For uploading, choose the cu entry. The tty variant waits for a modem signal that the Arduino does not send. The IDE normally lists only the cu variants, but other tools show both.
The number or suffix after the name changes depending on which USB socket you use and in what order devices were attached. Do not memorize "COM3". Read the list each time.
Selecting the port in the IDE
- Plug in the board and wait a few seconds for the operating system to recognize it.
- Open the Tools menu and choose Port.
- Pick the entry for your board. The IDE usually appends the board name in parentheses, for example
COM5 (Arduino Uno). - Confirm that the selection is shown. A checkmark appears next to the chosen port, and the board and port names show in the toolbar's board selector.
In Arduino IDE 2.x there is also a drop-down in the toolbar next to the Verify and Upload buttons. It lists detected boards together with their ports, and selecting one sets both. If you pick a board here, the IDE fills in the board type and the port in one step. This works well for official boards that identify themselves. It is less reliable for clones, which often report a generic chip name.
The test: unplug and replug
When the list holds several entries, you can identify your board with a simple comparison.
- Open Tools > Port and note every entry.
- Unplug the board and open the menu again.
- The entry that disappeared is your board.
- Plug it back in and select that entry.
This is the most dependable method on any platform. It works for clones that show as "Unknown" and for boards from other vendors.
Why a port might not appear
An empty list or a missing entry has a limited set of causes. Work through them from the cheapest check to the most involved.
The cable carries power only
Some USB cables have no data wires. They charge a phone but give the computer nothing to detect. The board will power on, and its power LED will light, but no port appears. Swap in a cable that you know carries data, such as one that has transferred files from a phone.
The connection is not fully seated
Check both ends of the cable. Try another USB socket on the computer, and avoid unpowered hubs when you can. A hub that cannot supply enough current causes intermittent disconnects.
The driver is missing
The operating system needs a driver for the USB-to-serial chip.
- Official boards with an ATmega16U2 are recognized by the drivers that the IDE installs on Windows. On macOS and Linux they work without extra drivers.
- Many clones use a CH340 or CH341 chip. On Windows and older macOS versions you may have to install the manufacturer's driver. Recent Linux kernels and recent macOS releases include support.
- Boards with a CP210x chip need the Silicon Labs driver on some systems.
You can see whether Windows detected the device in Device Manager. Look under Ports (COM & LPT) for the entry. An item under Other devices with a warning icon means the device is attached but has no driver.
Linux permissions
On Linux the port is a file, and your user account needs permission to open it. The device usually belongs to the dialout group (or uucp on some distributions). If the port is listed but upload fails with "Permission denied", add your user to the group, then log out and back in.
sudo usermod -a -G dialout $USERYou can list the devices the kernel sees and check ownership with these commands.
ls -l /dev/ttyACM* /dev/ttyUSB*
dmesg | tailThe dmesg output shows a line when you plug in the board, naming the device it attached to. If nothing appears there, the problem is the cable, socket, or hardware, not the IDE.
Another program holds the port
Only one program can open a serial port at a time. If a Serial Monitor window, a second IDE window, or a terminal program is connected, the upload fails or the port is reported as busy. Close the other program and try again. Closing the Serial Monitor tab before uploading is a good habit.
Boards that change port during upload
Some native USB boards, such as the Leonardo, Micro, and Nano 33 or MKR boards, behave differently. To upload, the IDE opens the port at 1200 baud and closes it. This "1200 bps touch" makes the board reset into its bootloader. While in the bootloader, the board shows up as a different port, often with a new number. The IDE detects this and finishes the upload on the new port. Afterwards your sketch restarts and the original port returns.
Two consequences follow. First, the port number in the menu may change after an upload, which is normal. Second, if a sketch crashes or never calls loop() correctly, the board can lose its USB response and the port vanishes. In that case, double-press the reset button to force the bootloader. The board then appears as a port, and you can upload a working sketch.
The classic Uno does not do this. Its converter chip stays attached the whole time, so the port keeps its name.
Checking that the port works
A listed port is not proof that uploading will succeed. The quickest proof is to upload Blink and see the LED change. To test the connection itself, you can open the Serial Monitor on the chosen port with a sketch like this one.
void setup() {
Serial.begin(9600);
}
void loop() {
Serial.println("Hello, Arduino!");
delay(1000);
}If text arrives at 9600 baud, the port is working in both directions as far as the board's output goes. A later chapter covers the Serial Monitor in detail.
Common error messages
| Message (abbreviated) | Likely meaning | What to try |
|---|---|---|
| `Port not selected` or the Upload button refuses | No port is chosen | Choose one in **Tools > Port**. |
| `Permission denied` on `/dev/tty...` | Linux account cannot open the device | Add yourself to `dialout`, then log out and in. |
| `Access is denied` or `port busy` on `COM` | Another program has the port | Close the Serial Monitor and other terminal programs. |
| `not in sync: resp=0x00` | Wrong board, wrong port, or no response from the chip | Check both selections, try another cable. |
| Port missing in the menu | Cable, driver, or hardware problem | Follow the checks above. |
Summary of the decision process
- Plug in the board and open Tools > Port.
- If one entry carries your board's name, choose it.
- If several appear, use the unplug-and-replug comparison.
- If none appears, check the cable, then the socket, then the driver, then Linux group membership.
- Close any program that may be holding the port before you upload.
Exercise
You open Tools > Port with an Uno connected on Linux and see both /dev/ttyACM0 and /dev/ttyS0. Name a way to tell which one is the Arduino. Then say what the most likely cause is if uploading to the right port gives "Permission denied".
Show answer
Unplug the board, reopen the menu, and see which entry disappears. That is the Arduino, here most likely /dev/ttyACM0, since /dev/ttyS0 is a built-in hardware serial port. "Permission denied" most likely means your user is not in the dialout group (or uucp on some distributions). Add yourself with sudo usermod -a -G dialout $USER, then log out and back in.
Exercise
A Leonardo uploads successfully, but afterwards the port number in the menu has changed from COM5 to COM6, and a moment later is COM5 again. Is something broken? Explain why this happens.
Show answer
Nothing is broken. The IDE opens the port at 1200 baud, which makes the board reset into its bootloader. The bootloader appears as a separate port (COM6) and the upload runs over it. When the new sketch starts, the board returns to its normal port (COM5).