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. ![]()
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
}