Three ways to reset an Arduino Board by code

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.
That’s all,


Related Posts

12 thoughts on “Three ways to reset an Arduino Board by code

  1. Hi,

    IIUIC, the AVR datasheet specifically does not recommend the IO pin to reset method. During the reset the AVR sets all its IO to inputs or high Z, which means the reset pulse is not held long enough ? If the data sheet says don’t do it, its probably best not to ?

    Also, IIUIC, the watchdog method isn’t that straight forward either ? you have to disable the watchdog immediately after reboot, as the watchdog setting survives the reboot ? and you'll be stuck in an endless reboot cycle ?



  2. Jon,

    To correctly use the watchdog reset, one should reburn his/her bootloader.

    Many use that method to upload a new sketch via bluetooth.

  3. Pingback: Things We Make » amplifIR
  4. On an Arduino Micro with a Caterina bootloader the ‘proper’ procedure is:
    #include “”
    void reboot(void) {
    #define BOOTKEY 0x7777
    #define ADRBKEY *(unsigned short *)0x0800
    while (1);

  5. hi i upload the watchdog timer code. it works. but here is a problem. now every 15ms this arduino will be restart. so i can not upload another program. i think my arduino is totally dead. please help me

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.