Arduino Nano error uploading

i'm using arduino nano for my project, at first is always stuck on uploading and now are like this, i'm using this code

#include <Servo.h>
Servo servo;
int angle = 10;
// defines pins numbers
const int trigPin = 12;
const int echoPin = 11;
// defines variables
long duration;
int distance;
void setup() {
   servo.attach(8);
  servo.write(angle);
pinMode(trigPin, OUTPUT); // Sets the trigPin as an Output
pinMode(echoPin, INPUT); // Sets the echoPin as an Input
Serial.begin(9600); // Starts the serial communication
}
void loop() {
// Clears the trigPin
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Sets the trigPin on HIGH state for 10 micro seconds
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Reads the echoPin, returns the sound wave travel time in microseconds
duration = pulseIn(echoPin, HIGH);
// Calculating the distance
distance= duration*0.034/2;
// Prints the distance on the Serial Monitor
Serial.print("Distance: ");
Serial.println(distance);
delay(10);

if(distance<100)
{
  servo.write(180);
  delay(4000);
  }
  else
  {
    servo.write(0);
    }
}

And then, it's stuck "Uploading Sketch" the light turns on when I plug it in, so the arduino seems to work (at least the on-board LED) can anybody help please?

I suggest that you try the different options under tools/processor in the IDE.

In IDE 2.x and IDE 1.x (you might have to update the AVR board package depending on the exact IDE version that is installed), there should be 3 options

  1. 328P
  2. 328P old bootloader
  3. 168

Most clones (and older original Nanos) need the second option; on newer original Nanos you will need to use the first option.

Welcome to the forum

What have you got Tools/Processor set to in the IDE ?

Sketch uses 4278 bytes (13%) of program storage space. Maximum is 30720 bytes.
Global variables use 241 bytes (11%) of dynamic memory, leaving 1807 bytes for local variables. Maximum is 2048 bytes.
"C:\Users\Gabriela Accenthiz\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/bin/avrdude" "-CC:\Users\Gabriela Accenthiz\AppData\Local\Arduino15\packages\arduino\tools\avrdude\6.3.0-arduino17/etc/avrdude.conf" -v -V -patmega328p -carduino "-PCOM6" -b57600 -D "-Uflash:w:C:\Users\Gabriela Accenthiz\AppData\Local\Temp\arduino\sketches\DB1FBC6F47AB74C85E402C95E072B5A2/T4_SAMPAH.ino.hex:i"

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

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

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

avrdude done. Thank you.

Failed uploading: uploading error: exit status 1

after i try to use the 328P old bootloader, it looks like this

looks like wrong comport

What COM-port do you see in the device-manager if you have plugged in your arduino nano ?

A few points

  1. Does COM6 disappear when you disconnect the Nano? If not, it's not the Nano.
  2. As far as I know, on some Windows systems Windows might think that it's a Bluetooth device. You can check if disabling Bluetooth in Windows solves the issue at hand.

Can you please post a picture of your Nano?

Thanks.. Tom.. :smiley: :+1: :coffee: :australia:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.