Can upload to MEGA but not to UNO??

Hi everyone. I'm a bit of a newbee on here so I hope you'll be patient with me.

I am currently finding it impossible to upload any code to either of my 2 UNO boards. However, each of the codes I have tried do successfully upload to my MEGA board.

Below is the error code I receive whenever I attempt to upload code to either of the UNO board:

Arduino: 1.8.9 (Windows 10), Board: "Arduino/Genuino Uno"

Sketch uses 444 bytes (1%) of program storage space. Maximum is 32256 bytes.
Global variables use 9 bytes (0%) of dynamic memory, leaving 2039 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't set com-state for "\\.\COM4"
An error occurred while uploading the sketch

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

I would really appreciate it if anyone could help me fix this ASAP.

Thank you in advance.
Lydia Barnes

Make sure you have selected the port of your Uno from the Tools > Port menu. The port of the Uno will likely be different from the port of the Mega, so you need to change the Tools > Port menu selection after using your Mega.

Sometimes the port will be labeled with the board name in the menu. Other times it will not. If you don’t know which port is your Arduino, you can find it like this:

  • Unplug your Arduino board from the computer.
  • Tools > Port
  • Note the ports, if any, listed in the menu.
  • Close the Tools menu
  • Plug your Arduino board into the computer.
  • Tools > Port - The new port listed in the menu is your Arduino board.

And select UNO or Mega from the board list.

Are the UNO’s genuine boards ? Some of the clones require a non standard driver - eg CH340


Thank you all very much for the advice.

@pert - Unfortunately I have already tried this and found it produces the same error message.

@hammy - This is also something I checked before each upload attempt with no success, regrettably.

With regards to your other question, one of the UNO boards and the MEGA board is genuine. The other UNO is an elegoo UNO R3 which has worked for me in the past with the same code so it would surprise me if it no longer worked.

@spycatcher2k - I have also tried this, and while it works the first time I upload after restarting, if I try to amend the code and re-upload it the same problem arises (which has resulted in me continuously restarting my laptop).

I have also considered the possibility that it is an issue with my computer. However, I have been using arduino on it for the last 2 years without incident but took a break for the last 6 months to work on other projects. Since returning to it a month ago, at which point I updated to the 1.8.9. version, I have only been programming using the MEGA (with no problems) - however, due to compatibility issues for my latest project an UNO board is required, which is when my problems began.

If you have any other suggestions I would be very grateful.

Many thanks and kind regards,
Lydia Barnes