Avrdude: ser_open(): can't open device "\\.\COM3": Access is denied

Hello,

I have been trying to upload a very simple script to my Arduiono Mega 2560 but I have been getting this error: [Enter error]

I tried using my fake Uno (yourDuino - got it in some set) and I got this error on Com10: avrdude: ser_open(): can't open device "\.\COM10": The system cannot find the file specified.

Unplugged Mega and ran code on fake Uno, got this: avrdude: ser_open(): can't open device "\.\COM3": Access is denied.

I have tried changing the ports on both devices - doesn't work.

I have been trying to get this working for ages, does anyone know how to fix it?

Code (I doubt there is anything wrong with it):

#define buzzerPort 13

int secondsToLaunch = 30;


void setup() {
  // put your setup code here, to run once:
  pinMode(buzzerPort, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:

  for(int i = 0; i <= secondsToLaunch; i++) {
    digitalWrite(buzzerPort, HIGH);
    delay(100);
    digitalWrite(buzzerPort, LOW);
    delay(900);
  }
  
}

some people had the same issue ten+ years ago... have you explored answers

here is one: avrdude: ser_open(): can't open device "\\.\COM3": Access is denied. - #7 by nivesh

My Mega is an Official Board, would the drivers linked in the first reply still work or would I break it?

the official MEGA board does not need a driver on most computers
assuming you are using Windows, if you plug and unplug the board, do you see it appearing in the com ports?

Yup, It appears in the Device manager and in the Arduino IDE.

and you selected MEGA as your target board before trying to upload?

go to preferences, set everything in verbose mode
make sure no serial monitor is open
try to compile (for Arduino MEGA) and upload (to the right selected Serial port) the following code

void setup() {}
void loop() {}

copy and paste what you see in the compilation window (under the code)


avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : wiring
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega2560
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PA0
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    10     8    0 no       4096    8      0  9000  9000 0x00 0x00
           flash         65    10   256    0 yes    262144  256   1024  4500  4500 0x00 0x00
           lfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           lock           0     0     0    0 no          1    0      0  9000  9000 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Wiring
         Description     : Wiring
         Programmer Model: AVRISP
         Hardware Version: 15
         Firmware Version Master : 2.10
         Vtarget         : 0.0 V
         SCK period      : 0.1 us

avrdude: AVR device initialized and ready to accept instructions

It says that the Upload is done.

so it's all working :slight_smile:
try with blink

Unfortunately not, I get this when I run it now: avrdude: ser_open(): can't open device "\.\COM3": Access is denied.

Im going to try the blink on my Chinese Uno

I got this when I uploaded the blink.

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
avrdude: ser_open(): can't open device "\\.\COM3": Access is denied.



avrdude done.  Thank you.

Problem uploading to board.  See http://www.arduino.cc/en/Guide/Troubleshooting#upload for suggestions.

I got this from the blank script:

avrdude: Version 6.3-20190619
         Copyright (c) 2000-2005 Brian Dean, http://www.bdmicro.com/
         Copyright (c) 2007-2014 Joerg Wunsch

         System wide configuration file is "C:\Users\User\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

         Using Port                    : COM3
         Using Programmer              : arduino
         Overriding Baud Rate          : 115200
         AVR Part                      : ATmega328P
         Chip Erase delay              : 9000 us
         PAGEL                         : PD7
         BS2                           : PC2
         RESET disposition             : dedicated
         RETRY pulse                   : SCK
         serial program mode           : yes
         parallel program mode         : yes
         Timeout                       : 200
         StabDelay                     : 100
         CmdexeDelay                   : 25
         SyncLoops                     : 32
         ByteDelay                     : 0
         PollIndex                     : 3
         PollValue                     : 0x53
         Memory Detail                 :

                                  Block Poll               Page                       Polled
           Memory Type Mode Delay Size  Indx Paged  Size   Size #Pages MinW  MaxW   ReadBack
           ----------- ---- ----- ----- ---- ------ ------ ---- ------ ----- ----- ---------
           eeprom        65    20     4    0 no       1024    4      0  3600  3600 0xff 0xff
           flash         65     6   128    0 yes     32768  128    256  4500  4500 0xff 0xff
           lfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           hfuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           efuse          0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           lock           0     0     0    0 no          1    0      0  4500  4500 0x00 0x00
           calibration    0     0     0    0 no          1    0      0     0     0 0x00 0x00
           signature      0     0     0    0 no          3    0      0     0     0 0x00 0x00

         Programmer Type : Arduino
         Description     : Arduino
         Hardware Version: 3
         Firmware Version: 4.4
         Vtarget         : 0.3 V
         Varef           : 0.3 V
         Oscillator      : 28.800 kHz
         SCK period      : 3.3 us

avrdude: AVR device initialized and ready to accept instructions

Reading | ################################################## | 100% 0.00s

avrdude: Device signature = 0x1e950f (probably m328p)
avrdude: reading input file "C:\Users\User\AppData\Local\Temp\arduino_build_382947/TEST.ino.hex"
avrdude: writing flash (444 bytes):

Writing | ################################################## | 100% 0.08s

avrdude: 444 bytes of flash written
avrdude: verifying flash memory against C:\Users\User\AppData\Local\Temp\arduino_build_382947/TEST.ino.hex:
avrdude: load data flash data from input file C:\Users\User\AppData\Local\Temp\arduino_build_382947/TEST.ino.hex:
avrdude: input file C:\Users\User\AppData\Local\Temp\arduino_build_382947/TEST.ino.hex contains 444 bytes
avrdude: reading on-chip flash data:

Reading | ################################################## | 100% 0.07s

avrdude: verifying ...
avrdude: 444 bytes of flash verified

avrdude done.  Thank you.

So the empty code works and uploading blink does not?

anything connected on your board?

try to hold reset and release it only when the compilation is finished and upload starts

The blank script no longer runs, same error: avrdude: ser_open(): can't open device "\.\COM3": Access is denied.

Neither of the other scripts run.

Edit: Just ran the blank script, it worked, then I ran the blink and it didn't work. I ran the blank script again and now it failed.

If you have the serial monitor open, then close it and try again.

I don't have the serial monitor open. I tried to open the serial monitor and it I got this: Error opening serial port 'COM3'. (Port busy)

I'm pretty sure that means that something else is using that port but I have previously tried changing ports with no effect.

Reboot the PC

Done, still the same error: avrdude: ser_open(): can't open device "\\.\COM3": Access is denied.

I’m no windows expert… so can’t help more. You would t need to find out what takes over the serial port (limited permissions, antivirus, virus on your pc,.…)

I will see what I can do, Thank you for your help :smiley:

Edit: I THINK I FIXED IT!

  1. Unplug Arduino.
  2. Run the code without the Arduino plugged in multiple times
  3. Plug Arduino back in
  4. Run code!

Another Edit: I have to redo the above steps every time I want to run the code. The blink code doesn't work on my Mega, the LED just stays on the whole time, no blinking, its connected to pin 13.

One more edit (I can't create new reply's because my account it too new):
I left my Arduino plugged in to my pc with the blink script uploaded for a while. Most of that time the LED stayed on, but after a while it started blinking!
Two things:

  1. I just uploaded the blink again script without errors.
  2. My old script gave me errors with uploading, LED is constantly on.

On no :frowning:

Update: Original Script now works if you use the steps above every time you want to run it.
Another Update: Can't open Serial Monitor + LED only complies with the script for a few seconds, then goes back to always on.

Yet another update: Moved to my old MacBook for my Arduino Coding - windows is stupid.