Hi all,
I have a strange issue in which the error message avrdude: ser_open(): can't open device "\\.\COM4": Access is denied.
appears when I try to upload certain programs to my Arduino Nano. This seems to occur for programs that involve some math operations
My Arduino Nano seems to be functional since I was able to upload programs about blinking LEDs and displays to the board without needing to pull out the USB cable. The strange thing is that all the problematic programs work without issues on my Mega 2560 board.
The code posted below is for the KS0033 temperature sensor from Key Studio. The wiring setup is shown in the image above.
void setup() {
Serial.begin(115200);
pinMode(A0, INPUT);
}
int reading;
double f, r, temperature;
String result = "Hello";
void loop() {
reading = analogRead(A0);
f = reading*5.0/1023.0;
r = 4700*(5 - f)/f;
temperature = 1/(log(r/10000)/3950 + 1/(25 + 273.15)) - 273.15;
result = String(reading) + String('\t') + String(temperature) + String("°C");
Serial.println(result);
}
When I try to upload this code to my Arduino Nano, I receive this error message. I will appreciate any help provided for resolving this issue.
Sketch uses 6516 bytes (21%) of program storage space. Maximum is 30720 bytes.
Global variables use 220 bytes (10%) of dynamic memory, leaving 1828 bytes for local variables. Maximum is 2048 bytes.
avrdude: ser_open(): can't open device "\\.\COM3": Access is denied.
Failed uploading: uploading error: exit status 1