Issue with com port

I have an issue with COM ports. I plug in my board and it connects to COM4. If I go to upload it goes through the compile function. Once it is ready to upload a fault comes up saying there is nothing on COM port 4. I open the COM port list and it is now connected to COM port 5. I start upload again, this time it completes and uploads the sketch. But immediately reverts back to being connected to COM Port 4.

Any ideas?

I moved your post to Installation & Troubleshooting as it's not a programming question

more details about your Arduino, your PC, the code you try etc would be an appropriate start.

I fail to see an issue? The Arduino uses a virtual USB connection, when it is placed into programming mode, it get issued a new com port.

Which Arduino product is this ? Which computer /OS.
Some eg Leonardo have the USB connection created by the processor , so when reset, it recreates the port and the computer may then give it a different number .

Yes, the Arduino can't control which port the PC puts it on. You have to poll or analyze the ports from your PC application in order to find the port that the Arduino is currently on.


Its a Nano33BLE previously used a Nano clone which this didn't happen with. I am using Win10 up to date on an ASUS Laptop 8MB RAM AMD QUAD Core E21.5gHz.
It is an issue as it takes four times as long to upload a sketch than it should, as it compiles, very slowly, then it drops Port 4, I have to choose port 5, then start upload again. This time it will upload, but drops port 5 when finished and have to choose port 4 again so I can choose serial monitor. Everything works fine other than this.

Sure, because the host performs the USB serial connection, so it begins a new serial instance every time you upload. The behaviour you are seeing is normal.

Edit - by the host, I mean the Arduino processor. oops

Thanks mate, didn't know that, just find it really annoying and drags the process out. If that is the way it is so be it.


There are other ways to program it. I'm not familiar with that board but there must be a debug port that you can use to program directly. Similar to the ICSP on the UNO.

If you think that's annoying, just wait until you upload sketch that runs wild and blows away the bootloader, rendering the serial connection dead.

thanks I will look into it tomorrow morning. I am new to this been a good learning curve needing to finish this project I am doing. Trying to get me head around switch cases too.

Not a good sign. Statistically, I've found that people who say they can't get their head around something, have less chance of success than those that say they're tearing their hair out. :slight_smile:

Have you found some good reference and tutorial information on switch/case?

already done that, been trying for two weeks to finish a sketch. Thought I'd ask for help before i go bald.

It's hard to ask, "what about switch/case don't you understand?" as the answer might be too general. But I can answer specific questions. Unlike some other subjects, C/C++ has a really good availability of references and tutorials online.

That is the thread, I think I should be close tomorrow with the suggestions, but if you have any by all means the more the better

Is that really a problem with switch/case, or a higher level design problem, though? ...

Sorry but have to go, off to bed. Thanks again for you help aarg. :beers:

Time zones are fun. Sleep on it.

well that I am unsure, it is with that part of the code only, the rest works. I thought the switch coding was right. That is why I am stuck, can't see a problem to fix


Issue fixed,no longer switches ports and also makes compiling heaps faster, I didn't know I had to put exemptions for real time virus scanning. Thanks for you assistance.