Sometimes it can be useful if the Arduino UNO could reboot itself without having to push the reset button on the board.

There are at least two ways to do the job.

Solution one. The dirty solution.

This solution moves the control to the beginning of the program using an assembly statement jump.

It is not a very complete solution because it doesn’t reset all the hardware connected to the Arduino board. Thus means that default configurations of the hardware will not be restored.

Here you are the function to call to reset the Arduino.

void software_Reset()
// Restarts program from beginning but 
// does not reset the peripherals and registers
{
  asm volatile ("  jmp 0");  
} 

arduino

Solution Two. The Watchdog

I think this is the clean way. It uses the watchdog to reset the board, and the job of a watchdog is the reset of a board……

On Arduino Mega 2560, the bootloader could not support the watchdog; to use it, you shall install a bootloader supporting the watchdog.

google for “arduino mega watchdog bootloader”

You can have the same problem with other Arduino boards, so before using wdt_enable, please verify that the bootloader, used by your board, supports wdt_enable

The needed structure are in the avr/wdt.h file, to enable you have to call the function wdt_enable(); it accepts as parameter the time before the board will be reset if no watchdog reset will be issued.

You can choose between several predefined values :

15mS    WDTO_15MS
30mS    WDTO_30MS
60mS    WDTO_60MS
120mS   WDTO_120MS
250mS   WDTO_250MS
500mS   WDTO_500MS
1S      WDTO_1S
2S      WDTO_2S
4S      WDTO_4S
8S      WDTO_8S

Then to reset the board you have only to implement a short loop, when the timeout expires the system reboots (by francisco). In the following example I have used the minimum value for the timeout. Just call software_Reboot to reboot your board.
#include 

void< software_Reboot()
{
  wdt_enable(WDTO_15MS);
  while(1)
  {
  }
}

Solution Three. One wire solution

If you are using the watchdog timer for other useful stuff, you can use a wire to connect, via a 1K resistor,a Digital Pin (for example pin12) to the Reset Pin. Then you can use the following code:

void swhwReset()
{
  int pin=12;
  pinMode(pin, OUTPUT);      // sets the digital pin as output
  digitalWrite(ledPin, LOW); // sets the LED off
}

If you’ve found useful this post, please, make a visit to my linkedin profile gg1 to help me growing my ranking.
That’s all,

Gg1.