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.
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 :
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.
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:
If you’ve found useful this post, please, make a visit to my linkedin profile gg1 to help me growing my ranking.