5 Simple Ways to Reset Arduino


Uploading numerous lines of code with multiple loops in it might cause many errors. The only option for debugging such errors is often reset the Arduino. As I’ve done it multiple times, I’ll walk you through 5 simple ways to reset Arduino.

So, what are these 5 simple ways to reset Arduino? Whether through hardware: 1) using the reset button; 2) reset pin; 3) an external reset button; Or through software: 4) using the reset function; or 5) the watchdog timer method.

But those methods need to be implemented with great care, or you might wreck the entire board. By the end of this article, you’ll able to properly reset your Arduino without having to buy a new one.

If you’re using reset to stop an Arduino running, there are other ways to stop it from running its sketch. I wrote a guide on how to do this here: chipwired.com/stop-arduino-running/

What Is Arduino Reset?

Resetting your Arduino board is similar to unplugging it and then plugging it back in again.

When you reset your Arduino board, it starts executing the code from the first line of the program you have uploaded by clearing everything present in the ROM previously.

It is similar to pressing the restart button on your PC. When you restart your computer, it immediately ends all the processes which were running and starts the system again.

The reset option in Arduino allows your board to restart by resetting the AVR microcontroller chip embedded in it.

Why Should You Reset Your Arduino?

Things might not always go as planned, and the reset function will allow your Arduino to start executing the program from the very start.

1. To get rid of internal bugs

The code you have been trying to run might not be working because of an error in your Arduino. The reset option allows you to get rid of any internal bugs of your board.

2. To get out from infinite loops

If your Arduino board has stopped responding in the middle of the execution of a program, it means it’s probably stuck in an infinite loop, and it cannot get out of it on its own.

You need to reset your Arduino board for it to exit that loop, which is one of the main reasons why people use the reset option.

3. To troubleshoot errors

Resetting is the first option that pops into a programmer’s mind when they are executing an Arduino based program. It is the first step in troubleshooting errors, and most of the time, resetting the Arduino board solves the problem.

If you’re interested in all the ways your Arduino can hang, crash, or stop running, I recently wrote a whole guide to all of that here: chipwired.com/arduino-crash-hang-guide/

How to Reset Your Arduino?

We can divide the methods of resetting Arduino in two types – hardware and software, which means that you can either reset your Arduino through the board or using the Arduino IDE.

Or sometimes, you might need to try both of these methods to make sure your Arduino program runs flawlessly.

Resetting Arduino Through Hardware

You can reset your Arduino through hardware, i.e., by using your Arduino board. Here are some simple ways to do this:

1. Using the Reset Button

See that little orange button mounted on your Arduino UNO board? Pushing it is the simplest way to reset an Arduino board.

arduino-reset-button-orange

Or if you have some other board, you would still be able to see a tiny button embedded on it. That’s the reset button. Pushing this button will stop everything that’s going on with your Arduino board and take the execution back to the first line of your code.

2. Using the Reset Pin

If you look at your Arduino board closely, you will notice a reset pin present on it right beside the power pins.

arduino-reset-pin

One can use this pin (marked on red color) to reset the Arduino board. All you need to do is make the right connections, the reason why I marked two of them.

Here’s how the reset Arduino using the pin works:

  1. Connect the reset pin to one of the digital I/O pins on the board (preferably the 3.5 on my experience).
  2. Upload a code that resets your Arduino board. This one below should do the trick:
void setup() { // leave empty }
void loop()
{
mySetup();
while (// test application exit condition here )
{
// application loop code here
}
}
void mySetup() { //… init here }

In the code, you need to set the digital I/O pin (which you have connected to the RESET pin, in this case, pin 3.5) to high and declare it as an output pin.

This means, when the program starts executing, pin 3.5 will generate a high logic level output and feed it into the RESET pin, which will reset the Arduino, and it will begin running the code from the first line.

If the above code doesn’t work for your case, you can find a couple more samples of codes used to reset Arduino using the RESET here (check on the comments section to see one of them with a schematic diagram of the Arduino board as well).

3. Setting Up an External Reset Button

In case you are unable to reach the reset button of your Arduino board, or if there’s a shield placed on top of your board, then you need to set up an external reset button. All you need is a breadboard, a push button, and a pair of jumper wires along with your Arduino board.

Applying a low voltage for a least 2 microseconds to the RESET pin will reset the Arduino UNO, according to its datasheet, which means that you need to apply a low voltage to the RESET pin using the push button.

For this, you need to connect the push button in its normally open state with one side connected to the RESET pin and the other side to GND. In its normal position, the RESET pin will be high, but as soon as you press the button, it will connect to the GND pin and hence will be at a low logic level.

This technic will reset the Arduino without the need to upload any code to the board. Visit this website for a more detailed guide to setting up an external reset button for your Arduino board.

Resetting Arduino Through Software

In case your Arduino board is unreachable to the extent that you cannot make any external connections to it, then you need to know how to reset your Arduino board using the Arduino IDE.

Here are some simple ways which can help you reset your Arduino board through software.

4. Using the Reset Function

The easiest way to reset Arduino through programming is to use the built-in reset function resetFunc(), which is available in the Arduino libraries. All you need to do is write the code and call the reset function at address location 0.

This code will reset your Arduino board and start executing the program from the first line of code.

This method is the simplest of all since it needs no external circuitry, only a function has to be called, and you’re good to go.

If you need to check out a sample Arduino program that uses the reset function, then click here.

5. The Watchdog Timer Method

Another great way to reset your Arduino board is to use the watchdog timer method. This method uses the watchdog library to reset Arduino in case the program is not responding as it should, and it’s recommended by the AVR chip manufacturer. Thus, it’s one of the most preferred ways of resetting Arduino boards.

The header file must be included for the watchdog timer to work.

First, a timer needs to be enabled. The timer duration can vary from 15 milliseconds to 8 seconds, depending on your application. For instance, if you need to set up a timer of 30 seconds, then you’ll write wdt_enable(WDTO_30ms).

Similarly, you can vary the number of seconds and write them in place of ‘30ms’. The timer works by resetting the microcontroller if the program takes more time to execute than it usually should.

For instance, if the main program should take 40 ms to run, the watchdog timer is set up such that if the main program takes more than 40 ms to execute, then the microcontroller will be reset.

If the program functions normally, it will reset the watchdog timer before it touches zero. If the program hangs in a loop and is unable to reset the watchdog timer, then, in that case, an interrupt is generated which resets the Arduino.

For a more detailed explanation and a sample code of the watchdog timer, visit this website.

So, Are You Ready to Reset Your Arduino?

Now that you know what it takes to reset an Arduino board, you can easily reset your Arduino if it’s stuck in an infinite loop, or it has stopped responding.

This article has equipped you with both hardware and software resetting methods. All you need to do is make sure you’re executing the techniques correctly.

Let me know in the comments below if you’ve tried any of the methods I laid out in here. Did they work well in your case?

If not, then also let us know in the comment section so we can give you some useful tips!

Chris

Engineer and electronics enthusiast. Enjoys solving problems with electronics and programming.

Recent Posts