Code can't be uploaded.

Hi, I'm a student. Me and my group mates are working on a project. We are using Arduino Uno. I was trying out a battery level indicator circuit when the Arduino board suddenly stopped working. We are now facing a problem as the code cannot be uploaded on the Arduino board. The error was something like "stk500_recv(): programmer is not responding" (there was a long list of it). I have tried simple codes like Blinking LED but it still cannot be uploaded.

I have tried the loopback test method on this Arduino board and it does not work. I tried it on another Arduino board (that is working) with the same USB cable, the same laptop and it works. Does anyone know what might be wrong with my Arduino board and how I can fix it? I can only guess that there is something wrong with the USB to serial converter? I'm quite new to Arduino and I don't know much. I would appreciate some guidance. Thank you for reading, have a nice day ahead. :slight_smile:

This is the battery level indicator circuit:

This is the code used:

//Battery Level Indicator

int greenLed2 = 10;
int greenLed1 = 8;
int yellowLed2 = 7;
int yellowLed1 = 6;
int redLed = 5;

float vPow = 5.04321422; //Value calculated for more accurate reading with power supply
float r1 = 100000; //R1 = 100000 ohms
float r2 = 10000; //R2 = 10000 ohms

int analogValue = A2;
int ledDelay = 1000;

void setup()
{
pinMode(greenLed2, OUTPUT);
pinMode(greenLed1, OUTPUT);
pinMode(yellowLed2,OUTPUT);
pinMode(yellowLed1, OUTPUT);
pinMode(redLed, OUTPUT);
Serial.begin(9600);
}

void loop()
{
float Vout = (analogRead(2) * vPow) / 1024.0; //Convert analog reading to voltage
float Vin = Vout / (r2 / (r1 + r2)); //Voltage divider formula, Vout = Vin * (R2/R1+R2)

if( Vin >= 23.175 ) //75% - 100%
{
digitalWrite(redLed, HIGH);
digitalWrite(yellowLed1, HIGH);
digitalWrite(yellowLed2, HIGH);
digitalWrite(greenLed1, HIGH);
digitalWrite(greenLed2, HIGH);
}
else if (Vin >= 19.75 && Vin < 23.175) //50% - 75%
{
digitalWrite(redLed, HIGH);
digitalWrite(yellowLed1, HIGH);
digitalWrite(yellowLed2, HIGH);
digitalWrite(greenLed1, HIGH);
digitalWrite(greenLed2, LOW);
}
else if (Vin >= 16.325 && Vin < 19.75) //25% - 50%
{
digitalWrite(redLed, HIGH);
digitalWrite(yellowLed1, HIGH);
digitalWrite(yellowLed2, HIGH);
digitalWrite(greenLed1, LOW);
digitalWrite(greenLed2, LOW);
}
else if (Vin >= 13 && Vin < 16.325) //0% - 25%
{
digitalWrite(redLed, HIGH);
digitalWrite(yellowLed1, HIGH);
digitalWrite(yellowLed2, LOW);
digitalWrite(greenLed1, LOW);
digitalWrite(greenLed2, LOW);
}
else if(Vin < 13) //0%
{
digitalWrite(redLed, HIGH);
digitalWrite(yellowLed1, LOW);
digitalWrite(yellowLed2, LOW);
digitalWrite(greenLed1, LOW);
digitalWrite(greenLed2, LOW);
}
delay(ledDelay);
digitalWrite(redLed, LOW);
digitalWrite(yellowLed1, LOW);
digitalWrite(yellowLed2, LOW);
digitalWrite(greenLed1, LOW);
digitalWrite(greenLed2, LOW);
Serial.println(Vin); //Compare voltage reading on serial monitor with power supply to check accuracy
}

What value of current limiting resistor are you using for each LED?
Each output of the Arduino can only supply 40mA and the total for all outputs maximum is 200mA. So that is the first thing to check.

To diagnose forst check the voltage on the 5V and 3.3V rails. If they are ok it could be either the arduino chip or the usb to serial converter. As you have another Uno you could simply try swapping the chips over as they are socketed.

When you try to power the board from the DC jack, Does the Green LED glow?
If yes,

  1. Press RESET. Does LED 'L' blink thrice ?

If No,
Try feeding 5V to the 5V pin.
Does the Green LED glow ?
goto 1 ;

If 'L' blinks
a.Does the tiny chip near the USB jack gets HOT ?
b.Do you see any sign of smoke escape ?

-Malhar

Hi gblades, thanks for your reply. I'm using a 220ohms resistor in series with each LED. I tried to check the voltage on the 3.3V and 5V rails using a multimeter and they are okay. But i have not try swapping the ic, i will try that soon, thank you so much :slight_smile:

Hi, Malhar. Thanks for your reply. I will try out the procedure that you suggested but I have a question to ask. May I know how to feed 5V to the 5V pin of Arduino? Is it just connecting a 5V supply directly into the 5V pin of Arduino? And will it be dangerous for the Arduino board? Nevrtheless, I'm willing to try i out, thank you :slight_smile:

NurHidayah:
Is it just connecting a 5V supply directly into the 5V pin of Arduino? And will it be dangerous for the Arduino board?

Yes. It will not damage your board. just make sure that the supply is 5V.

Before swapping the chips, number the chips and board to avoid the confusion.

The faulty board is not passing the loopback test,right ?
So the USB to Serial chip is dead or the main chip is shorted internally and it is not letting the board to work. Confirm the voltage on 5v and 3v3 while powering the board from USB as @gblades said.

Greetings,
Malhar

My problem has similarities. Upload of even the simplest of the learning sketches does not happen.

I have an UNO R3 board that I have been using for several months. With it, I have been through many of the beginning sketches without problems. I have, also, worked through several of the LCD sketches without problems.

Then, I purchased a second UNO R3 board. It behaved, as expected when I first powered it with the pin 13 LED blinking. Later, I tried to upload sketches that I had used on the first board without success.

Not only did the TX and RX LEDs not blink as I had experienced with the first board, I got a page worth of verbose text that included: “avrdude: ser_open(): can't open device "\.\COM5": “The system cannot find the file specified.” and “Problem uploading to board.

I can go back to the original board and successfully upload the same sketchs using any one of my ATmega328P-PU chips with bootloader. When I press the reset button, the #13 LED blinks three times. When I try to upload a sketch, none of the LEDs blink.

I've attached the error message for one of the simple LED sketches.

My computer is has a Windows 7 operating system and the USB cable and com port are the same for both boards.

New UNO - sketch 03_09.txt (16.5 KB)

@ rhdudley

Does the second board show up on the computer under "Com Ports" in device manager ?
Can you actually see it in the IDE with only that board connected ?
Does it work at all with everything disconnected from the board ?

Not all R3 UNO's are the same especially those from China.

@Malhar

Yes the loopback test failed on my faulty arduino board. I have tried feeding 5v to the arduino board.

When i power up the board, the green LED is on.
I pressed the reset button but 'L' does not blink.

Then i connect 5V to the 5V pin of the arduino board.
The green LED is on.

I then pressed the reset button again.
'L' still does not blink.

And the chip near the USB jack doesn't get hot and i don't see any smoke.

I already double check the voltage on 5v and 3v3 and they're both okay.

I'm guessing that maybe I accidentally exceeded 5V to analog pin A2 despite using resistors to protect it. I kept disconnecting and reconnecting the 16V battery because I didn't want any overheating to happen. And the Arduino stopped working when i wanted to reconnect the battery. Did my actions cause the USB to serial chip to be dead or main chip to be shorted internally? Does it make sense?

Thanks anyway, :slight_smile:

@Ballscrewbob

Thanks for the response.

Using the terminology: “old board” for the one that I have been using successfully and “new board” for the one that doesn’t work.

New Board

  1. shows no information when looking at Tools>Port.
  2. Brings up no information box when looking at Tools>Get board info.
  3. With nothing external except the USB cable connected to the computer and
    the ATmega328P-PU w/bootloader in place there is no response to the upload button.
  4. The #13 LED blinks in response to the reset button.

Old Board

  1. Shows Port: “Com 5 (Arduino/Genuino Uno”) and when hovering the cursor over that line shows that information repeated.
  2. When looking at Tools>Get board info it brings up an information box containing VID, PID, and SN.
  3. With nothing external except the USB cable connected to the computer and
    the ATmega328P-PU w/bootloader in place it responds normally with blinking TX and RX LEDs and finally the #13 LED on steady.
  4. The #13 LED blinks in response to the reset button.

Both boards are marked “assembled in USA. Both boards

@ rhdudley

Assembled in USA means very little. I have seen first hand the lengths companies will go to to be able to use such tactics.

Most cars are assembled in whatever country but in most cases a majority of the parts come from pretty much anywhere inc engines from China or India for so called "American / Canadian" cars

Few suggestions and ignore if you have already tried them.

Another USB cable. (or maybe more than 1)
With or without a USB 2 "self powered hub".
Different USB2 ports NOT USB3.
Another computer and or OS. (probably not the cause but still worth a shot)

My first thoughts would be driver issues seeing as you don't see anything in the ports sections.
These could be the CH341SER.EXE - 南京沁恒微电子股份有限公司
Instructions here

@Ballscrewbob

Success!!!
Thanks for all the responses!! And thanks to the Forum!

Your comments lead me to believe that I had a driver problem.
I tried (unsuccessfully) to find the driver file among the prior download I used for my first UNO.
So, I connected the new UNO USB to the computer and downloaded the Arduino software again. Then I searched for and found the driver. There was a Com port (with a new number) and the board info was also there. From there the UNO functioned as I was accustomed with the old board. I have, successfully, uploaded several sketches and everything behaves as expected.

My initial (wrong) assumption was that once a driver was acquired it would apply to any board. Not that a separate driver was needed for each board. Even the Com number was different for each board. I guess that a different Com number is necessary if more that one board is active on the same computer at the same time.

All the best,
RHDudley