Locked out from Arduino Uno

Heyoo,

Recently I have received my official Arduino Uno Rev3. It was working quite fine until yesterday evening when, after one sketch upload, it does not show up in the Device Manager anymore (or basically anywhere else...). The ON LED is lit very bright, the other LED next to the L silkscreen text, close to pin 13 blinks when I attach the cable, but then it starts to provide a very pale light. I have read a bunch of articles already and I have tried what all of these suggest:

  1. Rebooting my computer.
  2. Reinstalling the whole Arduino IDE with everything.
  3. Try another port.
  4. Unplug then re-plug the Arduino.
  5. Try a different computer.
  6. Press the RESET button while plugging out the USB cable and keep it pressed while plugging it back in.
  7. All the possible combinations for 1)-6).
  8. I was wondering whether the cable is bad, but at my workplace I managed to find another Arduino Uno and it works perfectly with the cable. So the cable should be OK.
  9. Crying myself into sleep.

Even though I designed a custom made shield, it's not attached when I upload the code and it wasn't attached (basically nothing was attached except for the USB cable) when I tried 1)-8). The shield didn't kill it, because it was working with it perfectly fine for a day. The shield I designed contains (among other things) 3 buttons and an LED and by pressing the buttons the LED is switching on and off as it's supposed to do, so the code (which is not nearly ready) runs on the Arduino Uno. So my main suspicion is that the communication line is broken somehow. I'm just not sure if it's possible to fix it... I hope there's a genius mind within this community who could help me with this. :slight_smile:

Bests,
Loki

If you remove the USB and apply a 9vdc to the power port, does the sketch run when you press reset?

Let me try to find a 9V adapter, I will reply as soon as I tried this.

Yep, it does.

Oh yeah, one more thing: I kept this plastic tray-thingy on the bottom of the Arduino so it's rather impossible for something to get under it an cause short circuit.

What was all connected to the board when it failed? What was the last sketch that you loaded?

If Windows device manager does not see the board, the 16U2 chip is not functioning properly. You can try to burn the firmware again using Atmel Flip; if that fails, I think that you can say that the 16U2 is toast.

You can buy a TTL-to-USB adapter (e.g. https://www.sparkfun.com/products/9716) and hookit up to the TX and RX pins of the Arduino and connect the DTR pin to the Arduino reset pin.

Note:
I assume that your board has a 16U2 (the chip closest to the USB port) as you mention official Arduino Uno Rev3.

Just the board was connected to my PC via an USB cable, nothing else. I haven't tried Atmel flip before, does it require a specific hardware as well? I assume so that the 16U2 is a toast... Which is super annoying, because I don't know how that one got fried, but if it can be killed so easily, then I should buy 10-20 Arduino Unos to make them last for a month.... And yup, it's a legit / official (or how to say) Uno R3 from Mouser.

Firstly I welcome you to the Community
In very Small number of cases it happens some time that if you put something under the Arduino as You wrote

Ya its good but try removing the code and then attach does any change you see?

Secondly that are you able to see your devices (when connected) in Windows Device Manager

And last but not least try attaching 9v DC Power directly to the Arduino Power Port and check that the LED Glow brightly or Not

Hi Krishna,

Thanks for the reply. I'm not quite sure what you mean by removing the code. I'm not able to see it in Windows Device Manager when connected, that's the main problem. I've tried to attach +9V DC supply to the Arduino Power Port (the USB was not attached when I tried this) and it seems that my code was running, the ON LED was also glowing brightly.

Oo I see could you share the code which is still uploaded on the board as you wrote

Yes, here you go. This code is not nearly ready, the functions are not finished yet, they need to be completed, verified and simplified. Which I can not do, because I'm locked out.

//Milliseconds in a day.
#define dayInMillis 86400000

//Input pins for the buttons.
const int startFeedPin = 2;
const int openHatchPin = 3;
const int closeHatchPin = 4;

//PWM outputs and other variables for the motors.
const int motor_5_PWM = 5;
const int motor_4_PWM = 6;
const int motor_3_PWM = 9;
const int motor_2_PWM = 10;
const int motor_1_PWM = 11;
const int motorArray[5] = {motor_1_PWM, motor_2_PWM, motor_3_PWM, motor_4_PWM, motor_5_PWM};
int isMoved[5] = {0, 0, 0, 0, 0}; // Indicates if a certain motor has been rotated or not.

//Approximatelly 140ms delay means 90° of rotation.
const int rotate = 100;

//Motor enable.
const int _motorEN = 12;

//Variables for measuring time.
unsigned long currentTime = 0;
unsigned long previousTime = 0;

//Booleans for the feeding and hatch closing / opening algorithm.
bool feeding = false;
bool opening = false;
bool closing = false;

//Functions
void feedingSequence(bool *feed_p, int *isMoved_p, unsigned long *prev_t, unsigned long *curr_t); //If feeding button is pressed, starts the feeding sequence.
void hatchOpening(); //Opens up all the hatches if the button is pressed.
void hatchClosing(); //Closes all the hatches if the button is pressed.
void buttonCheck(bool *feed_p, bool *open_p, bool *close_p, unsigned long *prev_t); // Reading the button signals.
//void test(int *elem);

void setup() {
Serial.begin(9600);
//Pinmode setup.
pinMode(startFeedPin, INPUT);
pinMode(openHatchPin, INPUT);
pinMode(closeHatchPin, INPUT);
pinMode(_motorEN, OUTPUT);
pinMode(motor_5_PWM, OUTPUT);
pinMode(motor_4_PWM, OUTPUT);
pinMode(motor_3_PWM, OUTPUT);
pinMode(motor_2_PWM, OUTPUT);
pinMode(motor_1_PWM, OUTPUT);
pinMode(A5, OUTPUT); // A5: indicator LED. This pin has low active logic.

//Default output setup.
digitalWrite(A5, HIGH); //LED off.
digitalWrite(_motorEN, HIGH); //Motors disabled.
analogWrite(motor_1_PWM, 0); //Motor 1 PWM = 0.
analogWrite(motor_2_PWM, 0); //Motor 2 PWM = 0.
analogWrite(motor_3_PWM, 0); //Motor 3 PWM = 0.
analogWrite(motor_4_PWM, 0); //Motor 4 PWM = 0.
analogWrite(motor_5_PWM, 0); //Motor 5 PWM = 0.

}

void loop() {

//test(&isMoved[0]);
//Serial.println(isMoved[0]);
buttonCheck(&feeding, &opening, &closing, &previousTime); //Checking the buttons.
if (feeding == true){feedingSequence(&feeding, &isMoved[0], &previousTime, &currentTime);} //Obvious.
//if (opening == true){hatchOpening();} //Obvious.
//if (closing == true){hatchClosing();} //Obvious.
}

//void test(int *elem){*elem += 1; return;}

//Checking if the buttons were pressed.
void buttonCheck(bool *feed_p, bool *open_p, bool *close_p, unsigned long *prev_t){

//Checking if the feeding button was pressed.
int startFeed = digitalRead(startFeedPin);
if(startFeed == 1){*feed_p = true; *open_p = false; *close_p = false; *prev_t = millis(); digitalWrite(A5, LOW);}

//Checking if the open hatch button was pressed.
int openHatch = digitalRead(openHatchPin);
if(openHatch == 1){*feed_p = false; *open_p = true; *close_p = false; *prev_t = 0; digitalWrite(A5, HIGH);}

//Checking if the close hatch button was pressed.
int closeHatch = digitalRead(closeHatchPin);
if(closeHatch == 1){*feed_p = false; *open_p = false; *close_p = true; *prev_t = 0; digitalWrite(A5, HIGH);}

return;
}

//The feeding sequence.
void feedingSequence(bool *feed_p, int *isMoved_p, unsigned long *prev_t, unsigned long *curr_t){
//*curr_t = millis();
unsigned long currt = millis();
unsigned long diff = currt - (*prev_t);
if(diff >= 3000){
digitalWrite(_motorEN, LOW);
analogWrite(motorArray[0], 127);
/*delay(150);
analogWrite(motorArray[0], 0);
digitalWrite(_motorEN, HIGH);
digitalWrite(A5, HIGH);
feed_p = false;/
}

/*//"Checking the current time".
*curr_t = millis();
//Checking if the time spent is >= 1 day.
if ((*curr_t - *prev_t) >= 1000){
for (int i = 0; i <= 4; i++){
// If the current motor hasn't moved yet, move it.
int currentArrayElement = *(isMoved_p + i);
if (currentArrayElement == 0){
digitalWrite(_motorEN, LOW); //Motor enable.
analogWrite(motorArray[i], 127); //Start rotating.
delay(165); // Waiting.
analogWrite(motorArray[i], 0); //Stop rotating.
digitalWrite(_motorEN, HIGH); //Motor disable.
currentArrayElement = 1; //Setting the motor as "moved".
*prev_t = millis(); //Increasing the "previous time" value.
//Checking if we have reached the end of the array. If yes, reset the values.
if(i == 4){
for(int k = 0; k <= 4; k++){int cleanArray = *(isMoved_p + k); cleanArray = 0;} //Restoring array value to default.
digitalWrite(A5, HIGH); //Switch off LED.
*feed_p = false; //Setting feeding boolean
return;
}
return;
}
}
} */
return;
}

//Opening all hatches.
void hatchOpening(){
feeding = false; //If there was feeding, stop the current sequence.
digitalWrite(_motorEN, LOW); //Motor enable.
//Going through the array.
for (int i = 0; i <= 4; i++){
//If a motor hasn't been moved, move it.
if (isMoved[i] == 0){
analogWrite(motorArray[i], 100); //Start rotating.
delay(165); // Waiting.
analogWrite(motorArray[i], 0); //Stop rotating.
isMoved[i] = 1; //Setting the motor as "moved".
}
}
digitalWrite(_motorEN, HIGH); //Motor disable.
opening = false;
return;
}

//Closing all hatches.
void hatchClosing(){
feeding = false; //If there was feeding, stop the current sequence.
digitalWrite(_motorEN, LOW); //Motor enable.
//Going through the array.
for (int i = 0; i <= 4; i++){
//If a motor has been moved, move it again so the hatch will be closed.
if (isMoved[i] == 1){
analogWrite(motorArray[i], 127); //Start rotating.
delay(165); // Waiting.
analogWrite(motorArray[i], 0); //Stop rotating.
isMoved[i] = 0; //Setting the motor as "not moved". Or default state. Or whatevs.
}
}
digitalWrite(_motorEN, HIGH); //Motor disable.
closing = false;
return;
}

As per this I want to Ask you have used Arduino Uno R3 right?
And are you Beginner?

I have used Arduino Uno R3, yes. Well, I have done some easy-level programming years ago, my knowledge was pretty rusty, now with this hobby project I try to swipe down the dust (but I forgot a lot about programming). I'm working with electronics, so I did all the necessary precautions when using the Arduino.

That's a very good Habit but can you pls tell that what are you trying to or trying to make in the code you have uplaoded

Summary
//Milliseconds in a day.
#define dayInMillis 86400000

//Input pins for the buttons.
const int startFeedPin = 2;
const int openHatchPin = 3;
const int closeHatchPin = 4;

//PWM outputs and other variables for the motors.
const int motor_5_PWM = 5;
const int motor_4_PWM = 6;
const int motor_3_PWM = 9;
const int motor_2_PWM = 10;
const int motor_1_PWM = 11;
const int motorArray[5] = {motor_1_PWM, motor_2_PWM, motor_3_PWM, motor_4_PWM, motor_5_PWM};
int isMoved[5] = {0, 0, 0, 0, 0}; // Indicates if a certain motor has been rotated or not.

//Approximatelly 140ms delay means 90° of rotation.
const int rotate = 100;

//Motor enable.
const int _motorEN = 12;

//Variables for measuring time.
unsigned long currentTime = 0;
unsigned long previousTime = 0;

//Booleans for the feeding and hatch closing / opening algorithm.
bool feeding = false;
bool opening = false;
bool closing = false;

//Functions
void feedingSequence(bool *feed_p, int *isMoved_p, unsigned long *prev_t, unsigned long *curr_t); //If feeding button is pressed, starts the feeding sequence.
void hatchOpening(); //Opens up all the hatches if the button is pressed.
void hatchClosing(); //Closes all the hatches if the button is pressed.
void buttonCheck(bool *feed_p, bool *open_p, bool *close_p, unsigned long *prev_t); // Reading the button signals.
//void test(int *elem);

void setup() {
Serial.begin(9600);
//Pinmode setup.
pinMode(startFeedPin, INPUT);
pinMode(openHatchPin, INPUT);
pinMode(closeHatchPin, INPUT);
pinMode(_motorEN, OUTPUT);
pinMode(motor_5_PWM, OUTPUT);
pinMode(motor_4_PWM, OUTPUT);
pinMode(motor_3_PWM, OUTPUT);
pinMode(motor_2_PWM, OUTPUT);
pinMode(motor_1_PWM, OUTPUT);
pinMode(A5, OUTPUT); // A5: indicator LED. This pin has low active logic.

//Default output setup.
digitalWrite(A5, HIGH); //LED off.
digitalWrite(_motorEN, HIGH); //Motors disabled.
analogWrite(motor_1_PWM, 0); //Motor 1 PWM = 0.
analogWrite(motor_2_PWM, 0); //Motor 2 PWM = 0.
analogWrite(motor_3_PWM, 0); //Motor 3 PWM = 0.
analogWrite(motor_4_PWM, 0); //Motor 4 PWM = 0.
analogWrite(motor_5_PWM, 0); //Motor 5 PWM = 0.

}

void loop() {

//test(&isMoved[0]);
//Serial.println(isMoved[0]);
buttonCheck(&feeding, &opening, &closing, &previousTime); //Checking the buttons.
if (feeding == true){feedingSequence(&feeding, &isMoved[0], &previousTime, &currentTime);} //Obvious.
//if (opening == true){hatchOpening();} //Obvious.
//if (closing == true){hatchClosing();} //Obvious.
}

//void test(int *elem){*elem += 1; return;}

//Checking if the buttons were pressed.
void buttonCheck(bool *feed_p, bool *open_p, bool *close_p, unsigned long *prev_t){

//Checking if the feeding button was pressed.
int startFeed = digitalRead(startFeedPin);
if(startFeed == 1){*feed_p = true; *open_p = false; *close_p = false; *prev_t = millis(); digitalWrite(A5, LOW);}

//Checking if the open hatch button was pressed.
int openHatch = digitalRead(openHatchPin);
if(openHatch == 1){*feed_p = false; *open_p = true; *close_p = false; *prev_t = 0; digitalWrite(A5, HIGH);}

//Checking if the close hatch button was pressed.
int closeHatch = digitalRead(closeHatchPin);
if(closeHatch == 1){*feed_p = false; *open_p = false; *close_p = true; *prev_t = 0; digitalWrite(A5, HIGH);}

return;
}

//The feeding sequence.
void feedingSequence(bool *feed_p, int *isMoved_p, unsigned long *prev_t, unsigned long *curr_t){
//*curr_t = millis();
unsigned long currt = millis();
unsigned long diff = currt - (*prev_t);
if(diff >= 3000){
digitalWrite(_motorEN, LOW);
analogWrite(motorArray[0], 127);
/*delay(150);
analogWrite(motorArray[0], 0);
digitalWrite(_motorEN, HIGH);
digitalWrite(A5, HIGH);
feed_p = false;/
}

/*//"Checking the current time".
*curr_t = millis();
//Checking if the time spent is >= 1 day.
if ((*curr_t - *prev_t) >= 1000){
for (int i = 0; i <= 4; i++){
// If the current motor hasn't moved yet, move it.
int currentArrayElement = *(isMoved_p + i);
if (currentArrayElement == 0){
digitalWrite(_motorEN, LOW); //Motor enable.
analogWrite(motorArray[i], 127); //Start rotating.
delay(165); // Waiting.
analogWrite(motorArray[i], 0); //Stop rotating.
digitalWrite(_motorEN, HIGH); //Motor disable.
currentArrayElement = 1; //Setting the motor as "moved".
*prev_t = millis(); //Increasing the "previous time" value.
//Checking if we have reached the end of the array. If yes, reset the values.
if(i == 4){
for(int k = 0; k <= 4; k++){int cleanArray = *(isMoved_p + k); cleanArray = 0;} //Restoring array value to default.
digitalWrite(A5, HIGH); //Switch off LED.
*feed_p = false; //Setting feeding boolean
return;
}
return;
}
}
} */
return;
}

//Opening all hatches.
void hatchOpening(){
feeding = false; //If there was feeding, stop the current sequence.
digitalWrite(_motorEN, LOW); //Motor enable.
//Going through the array.
for (int i = 0; i <= 4; i++){
//If a motor hasn't been moved, move it.
if (isMoved[i] == 0){
analogWrite(motorArray[i], 100); //Start rotating.
delay(165); // Waiting.
analogWrite(motorArray[i], 0); //Stop rotating.
isMoved[i] = 1; //Setting the motor as "moved".
}
}
digitalWrite(_motorEN, HIGH); //Motor disable.
opening = false;
return;
}

//Closing all hatches.
void hatchClosing(){
feeding = false; //If there was feeding, stop the current sequence.
digitalWrite(_motorEN, LOW); //Motor enable.
//Going through the array.
for (int i = 0; i <= 4; i++){
//If a motor has been moved, move it again so the hatch will be closed.
if (isMoved[i] == 1){
analogWrite(motorArray[i], 127); //Start rotating.
delay(165); // Waiting.
analogWrite(motorArray[i], 0); //Stop rotating.
isMoved[i] = 0; //Setting the motor as "not moved". Or default state. Or whatevs.
}
}
digitalWrite(_motorEN, HIGH); //Motor disable.
closing = false;
return;
}






And secondly have you own design the code
Thirdly request you to whenever you paste the code always paste Preformatted text like this by pressing Ctrl + E

I am asking what you are trying to do in the code as sometimes while doing calculation or executing the program board can get out of Brain :sweat_smile:

So pls tell

In the end, the Arduino will control 5 small servos, which will open some hatches and from those hatches food will fall for my pet, so I'm making an automated feeder. At this state I wanted to test a part of a function, but then I lost connection to the Arduino and I can't fix my code anymore. Does it help in any way?

If this is true, your USB cable/port is bad.

If this is true, your USB cable/port is bad.

Well, no, because the same happened with another computer and I tried the same cable with another Arduino (which is not mine) and both laptop could recognize this other one.

Which is your UNO R3 version, an SMD or DIP version?

If it's the DIP version, maybe you can try to unplug the atmega328p-pu from the arduino uno's pcb, and make the atmega328p-pu minimum system.

I have the SMD one. :slight_smile: If I would have an ISP programmer, I could manage to program the MCU still, because it's working.