Arduino Reset Function Using Only Software

Here is a simple, clean and proper solution for doing a full Arduino reset via a simple software function. The general solution was found here and was implemented as follows:

Include the proper library:

#include <avr/wdt.h>

Place this within your “Setup” function:

MCUSR = 0;  // clear out any flags of prior resets (used for resetting board)

The sample ‘reset’ function:

void resetBoard(void){
  wdt_enable(WDTO_15MS); // turn on the WatchDog and don't stroke it.
  for(;;) { 
    // do nothing and wait for the eventual...
  } 
}

 

That’s it! Simply call resetBoard(); anywhere in your code when you wish to reset the board.

Leave a Reply

Your email address will not be published. Required fields are marked *