Arduino is bricked, stuck resetting itself, PLEASE HELP!

Hello to and thanks so much to whoever is reading this :sweat_smile:

Arduino board: Nano 328

I’ve recently used the soft reset library in one of my latest projects to be able to set the program back to square one at a certain point. However, I must have made a mistake when I uploaded, because somewhere in the program the arduino is told to constantly reset itself, the pin 13 LED is having a heart attack, and as it does that, I can’t send a program to it to stop

If there is a way to externally clear the program memory of the arduino it should be able to fix it, I don’t have any knowledge of a possible way to clear it.

So now i’m stuck trying to send a blank program to this board to clear it, and it not responding.

Any help would be GREATLY appreciated :smiley:
Thank you

(Here is the sketch I sent before things went south)

#include <avr/wdt.h>
bool toggle;
int pwm;

void setup() {
MCUSR = 0;
toggle = 0;
pwm = 128;
pinMode(2, INPUT);
pinMode(3, OUTPUT);
pinMode(5, OUTPUT);
attachInterrupt(0, start, FALLING);
}

void loop() {
analogWrite(5, pwm);
digitalWrite(4, LOW);
toggle = digitalRead(2);
if (toggle == 1) {
digitalWrite(4, HIGH);
digitalWrite(6, HIGH);
pwm = 1;
analogWrite(5, pwm);
delay(500);
pwm = 128;
analogWrite(5, pwm);
delay(2000);
pwm = 240;
analogWrite(5, pwm);
delay(2000);
pwm = 128;
digitalWrite(4, LOW);
analogWrite(5, pwm);
while(1 < 2) {
}
}

}

void start (){
** wdt_enable(WDTO_15MS);**
** for(;:wink: {**
}
}

(The bolden code is what I added before it died, and the for() has two semicolons in it.)

There is a bug in the old Nano bootloader that causes this reset loop behavior:

It has been fixed in the new official Arduino Nanos.

The best solution is to:

  • Connect an ISP programmer to your Nano. If you don't own a dedicated programmer you can use a spare Arduino board as an "Arduino as ISP". If you're buying one then I recommend the 6 pin USBasp programmer. You can buy them on eBay for ~$3 w/ free shipping from China.
  • Tools > Board > Arduino/Genuino Uno.
  • Tools > Programmer > select the appropriate programmer.
  • Tools > Burn Bootloader.

After doing that you must always select Tools > Board > Arduino/Genuino Uno when using your Nano. In addition to solving the watchdog bug, this will also free up 1.5 kB of program memory.

Thanks for the reply and help :smiley: