Arduino Software is not accessing my arduino device

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\meder\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf"

     Using Port                    : COM6
     Using Programmer              : arduino
     Overriding Baud Rate          : 115200

avrdude: ser_open(): can't open device "\.\COM6": Access is denied.

Show your code in code brackets and a circuit diagram of all connections including programmer used....NOT fritzing.

1 Like

can you use the Arduino IDE and select the Tools->Port tab with and without your Arduino plugged in. The correct COM port should appear only when the Arduino is connected

1 Like
// TM1637 Digital Clock with Setup and Alarm Functionality

#include  <Arduino.h>
#include <TM1637Display.h>
#include <virtuabotixRTC.h> //

//  RTC module declaration
// PINS CLK, DAT, RST
virtuabotixRTC myRTC(A1,A2,A3);

//  Variables to store previous values read off RTC module
int minutes;
int hours;
//  Variables to store the time at which Alarm should go off 
int Alarm_minutes=05;
int  Alarm_hours=18;
uint8_t Blank[] = {0x0};

int POSITION=0;

//Table  to store 4 digits, used in time and Alarm setup procedure
int digits[3];

int  interval=0;

#define Alarm 9 // Button to switch alarm mode on or off
#define  Buzer 13
#define Led 8


//Statuses
boolean Alarm_set=false;
boolean  Alarm_in_progress=false;
boolean Setup_on= false;

// 4digit display connection  pins (Digital Pins)
#define CLK 4
#define DIO 5


// 4 digit display  declaration
TM1637Display clock(CLK, DIO);

void setup() {
  
 attachInterrupt(digitalPinToInterrupt(2),  Press_A_Button,RISING);
 attachInterrupt(digitalPinToInterrupt(3), Press_B_Button,RISING);
  pinMode(Alarm, INPUT);
 pinMode(Buzer, OUTPUT);
 pinMode(Led, OUTPUT);
  digitalWrite(Buzer,LOW);
 clock.setBrightness(0x0f);
 Serial.begin(9600);
}

void  Press_A_Button(){
  if (interval>3){
    if (Setup_on==false){
      Setup_on=true;
      if (Alarm_set==true){
        digits[0]= (int)Alarm_hours/10;
        digits[1]=  Alarm_hours-((int)Alarm_hours/10)*10;
        digits[2]= (int)Alarm_minutes/10;
        digits[3]= Alarm_minutes-((int)Alarm_minutes/10)*10; 
      } 
      else  {
        digits[0]= (int)myRTC.hours/10;
        digits[1]= myRTC.hours-((int)myRTC.hours/10)*10;
        digits[2]= (int)myRTC.minutes/10;
        digits[3]= myRTC.minutes-((int)myRTC.minutes/10)*10;
      }
    }
    else{
      POSITION++;
      if (POSITION==4){
        if (Alarm_set==true){
          Alarm_minutes=digits[3]+digits[2]*10;
          Alarm_hours=digits[1]+digits[0]*10;
        } 
        else {
          myRTC.setDS1302Time( 0, digits[3]+digits[2]*10, digits[1]+digits[0]*10,myRTC.dayofweek,  myRTC.dayofmonth, myRTC.month, myRTC.year);
          clock.showNumberDec(digits[0],false,1,0);
          clock.showNumberDec(digits[1],false,1,1);
          clock.showNumberDec(digits[2],false,1,2);
         clock.showNumberDec(digits[3],false,1,3);
        }
        POSITION=0;
        Setup_on=false;
      }
    }
  }
  interval=0;
}

void  Press_B_Button(){
  if (interval>3){
    if(Setup_on){
      digits[POSITION]=digits[POSITION]+1;
      if (POSITION==0 and digits[POSITION]==3) digits[POSITION]=0;
      if (POSITION!=0  and digits[POSITION]==10) digits[POSITION]=0;
      interval=0;
    } 
  }
  interval=0;
}

void loop() {  
  if (digitalRead(Alarm)==HIGH  and Alarm_set==false ){
    if (interval>30){
      digitalWrite(Led,HIGH);
      Alarm_set=true;
      delay(300);
    }
  } else{
    if (digitalRead(Alarm)==HIGH  and Alarm_set==true){
      if (interval>30){
      Alarm_set=false;
      Alarm_in_progress=false;
      digitalWrite(Led,LOW);
      delay(300);
    }
   }
 }
 myRTC.updateTime();
  
 
 if (Setup_on==true){
    clock.showNumberDec(digits[0],false,1,0);
    clock.showNumberDec(digits[1],false,1,1);
    clock.showNumberDec(digits[2],false,1,2);
    clock.showNumberDec(digits[3],false,1,3);
    delay(200);
    clock.setSegments(Blank,  1,POSITION);  
    delay(200);
    clock.showNumberDec(digits[0],false,1,0);
    clock.showNumberDec(digits[1],false,1,1);
    clock.showNumberDec(digits[2],false,1,2);
    clock.showNumberDec(digits[3],false,1,3);
  }
 else{
   if (myRTC.minutes==Alarm_minutes  and myRTC.hours==Alarm_hours and Alarm_set==true and Setup_on==false){
    Alarm_in_progress=true;
   }

   if (Alarm_in_progress){
     digitalWrite(Buzer,HIGH);
     delay(1000);
     digitalWrite(Buzer,LOW);
     delay(1000);
   } 
   
 if (myRTC.minutes!=minutes){
    
   clock.showNumberDecEx((int)myRTC.hours/10*1000+(myRTC.hours-((int)myRTC.hours/10)*10)*100+  (int)myRTC.minutes/10*10+myRTC.minutes-((int)myRTC.minutes/10)*10, (0x80 >> 1),  true);

   minutes=myRTC.minutes;
   hours=myRTC.hours;
   
   }
  }
 if (interval<200) interval++;
}

The correct comm always appears its just when i click upload it says cannot access device

sure you specified the correct board
Tools->Board

What Arduino are you using?
What computer operating system are you using?

Is the Serial monitor closed when trying to upload?

access denied can be a a USB computer problem where something is blocking the port.

There is a tool called Process Explorer to see what that might be.

If your issue was not an open serial monitor and you need to use the process explorer tool, here are some links on how to use it.

I'm using arduino nano and im on windows 11 no its opened when i upload ill try using the process explorer and see if anything is blocking the port.

I used process explorer it said 0 searches found i went to device manager got the value put it in and there was nothing that was conflicting or blocking.

Yes i am using the right board it Says arduino nano under tool>board

Im not sure if this means anything but when i go to process explorer Arduino says access denied where it says path

Which bootloader?

I think there maybe some driver issues with the usb interface chip (CH340?)on the Nano and Windows 11.

Try the forum search bar and then Google to get you started.

I'm using ATmega328P I've tried both this one and the old one and it didn't make a difference

Bro thank you so much you helped me figure out the issue. it was a problem with my drivers i just uninstalled and reinstalled and it worked.

it was a problem with my drivers

Can you be more specific? I'm about to get a Windows 11 computer and I'm expecting my Arduino environment to be somewhat stormy. :wink:

The CH340 drivers were outdated and also their were duplicates so all i did was go to this website https://www.wch.cn/downloads/CH341SER_EXE.html when you download it it says uninstall and install i clicked uninstall then i installed the driver and it worked. I'm not sure if the issue was because there were duplicates of the same driver or because the drivers were outdated