I want to make Arduino auto reset itself

I want to make my Arduino reset itself using the reset pin and software. For example, if I connect the ground pin to the reset pin and release it, it will reset it. I tried to use the Blink sketch to alternative pin 13 (led) low and high every 5 seconds. I then connected pin 13 to the reset pin and ran the sketch. After 5 seconds of Pin 13 being high, it goes to low for 5 seconds and then back to high which I expected would trigger the reset pin but instead it kept the lead dim and the program would stop working until I removed the wire connected pin 13 to the reset pin.

Is there an easier way to reset the Arduino using a sketch? If not can anyone tell me what I might be doing wrong?

BTW I just tried using a 1.1k resister (1k didn't do anything) between the pin 13 and reset pin and once the 13 pin went low it would reset but it would keep on resetting (13 led keeps flashing). I am assuming it's like this because the program doesn't have a chance to start running and trigger the 13 pin back to high.

Hi,

see the following code snippet from user HULK

void(* resetFunc) (void) = 0; //declare reset function @ address 0 ... resetFunc(); //call reset ...

Mike

Thank you, but does that code reset the program or reset the Arduino? I need something to reset the Arduino. I tried out your code to print a bunch of hellos and then reset and the hellos never pause, it just keeps going

hello1 hello2 hello3 hello4 (reset) hello1 hello2 etc.,

With no pause which makes me think its a software reset.

This code should have the same effect as pressing the reset key of the Arduino board.

Mike

Well the code keeps going with no pauses, it just resets back to the first hello. I am in serial monitor and its supposed to reset when it says hello4 which it does but if i reset it manually it will take about 5 seconds for Arduino to load back up and start displaying the hello's to serial again. For example:

hello1 hello2 hello3 hello4 (software reset, arduino led does nothing, no time delay) hello1 hello2 hello3 hello4

or

hello1 hello2 hello3 hello4 (i push the reset button, arduino led flashes, serial monitor does nothing for about 5 seconds) then starts over) hello1 hello2 hello3 etc.

Isn't there supposed to be a delay?

A jump to program location 0 is not a true reset, it just starts your program from the start. It does not reset the internal functions nor starts the auto bootloader. The problem with trying to use a digital output pin to generate a reset pulse is that the when the AVR first starts the reset sequence the first thing it does is set all the I/O pins to tri-state inputs, thus removing the reset pulse too soon such that a full reset does not happen.

The watch dog timer option is one way to generate a true reset in software but it is not really compatible with the auto bootloader program and can effectively lock up the chip if not used correctly.

Of course with some external circuitry a simple 555 timer chip could be utilized to create a proper length reset pulse when triggered by an output pin, but again that would require external components.

Are you sure you really need to generate a reset? There is usually always ways to structure a program in a way to do what has to be done. Can you explain why you need it, or post your program?

Lefty

What about a transistor from reset to ground.

You could add a small cap to the base, maybe 1uf to hold the reset when chip powers out. (Auto reset is nothing more than a 100nF cap after all)

I'm thinking the transistor would also allow to send a high signal to trigger the connection to ground. You will need to make sure you use a pulldown resistor on the base as well, but I'd be curious to see someone try it.

There is an other trick to make a software reset: abuse the watchdog timer:

#include <avr/wdt.h>        // Include this to handle watchdog timer
cli();                  // Clear interrupts
wdt_enable(WDTO_15MS);      // Set the Watchdog to 15ms
while(1);            // Enter an infinite loop

After 15ms in the infinite loop, the Arduino will reset, jump into bootloader, find that it was not a hardware reset (this is something checked at the first instructions of the bootloader) and jump to your application.

There is a similar topic on AVR Freaks:
http://www.avrfreaks.net/index.php?name=PNphpBB2&file=printview&t=65123&start=0

Hi,

There is an other trick to make a software reset: abuse the watchdog timer:

It's not a trick, its the recommended way to reset a atmega from software.

After 15ms in the infinite loop, the Arduino will reset, jump into bootloader, find that it was not a hardware reset (this is something checked at the first instructions of the bootloader) and jump to your application.

But it's not that easy because the watchdog has to be reset in the bootloader-code, which AFAIK is only happening in the bootloader of the Arduino Pro 8MHz.

All others need a hardware-programmer to modify and upload the bootloader-code, or upload sketches directly using a programmer and this little article : http://www.nongnu.org/avr-libc/user-manual/FAQ.html#faq_softreset

Eberhard

Are you sure you really need to generate a reset? There is usually always ways to structure a program in a way to do what has to be done. Can you explain why you need it, or post your program?

Yes, I would be really interested to hear of the application need that calls for this solution. [Being a software engineer primarily, I tend to think that all problems can be solved via code :)]

I found by tying a PWM pin to the reset pin, you can just do an analogWrite(RESET, LOW); where RESET is your PWM pin. It's been doing a hard reset for me, working great.

Hi,

I found by tying a PWM pin to the reset pin, you can just do an analogWrite(RESET, LOW); where RESET is your PWM pin. It's been doing a hard reset for me, working great.

Fine it works for you, but others may be warned: Atmel the maker of the ATMega's discourages this. Because of timing issues it can lead to situations where the ATMega goes into an endless reset-loop.

Eberhard