Reprogramming, Erasing, and Resetting Arduino Uno Tutorial

New Arduino users will push the ‘Reset’ button without having any Arduino Uno tutorial to resetting their boards; something that will take you to ‘restart’ rather that reset. There are times when we want to reset Arduino to just make sure all functions are running properly. Or if Arduino in a state of hang/crashing for some reason, of course, we have to reset it. To manually reset the Arduino we would not be able to do if the Arduino-based control system we have built is already installed somewhere. The only way is to create a kind of auto-reset system or with detection if the Arduino is in a state of hang/crashs. For this tutorial, we will discuss how to reset Arduino with program code or software by not pressing the hardware reset button.

Reprogramming, Erasing, and Resetting Arduino Uno Tutorial

Resetting Arduino Uno tutorial using the ‘ku_reset’

Arduino-resets on a regular basis are very important for you to do especially on Arduino who work independently as a control system that works 24 hours continuously. This is to prevent Arduino become hang/crash and always makes it ‘fresh’ again. To reset Arduino with the program code taken from this Arduino Uno tutorial, you can define a function in the address of the Arduino program. So when you call this function in any place in your main program, you will basically go to address 0 in your Arduino. This will produce the same effect as when you pressed the Arduino reset button (hardware reset).

Pay attention to the method of defining the ‘ku_reset’ function to be at the address of 0 Arduino (line 1) and the method call to reset it (line 18). For more details, please open the Serial Monitor window via the Tools-Serial Monitor menu. Note that line 19 above will never be executed (not shown in Serial Monitor window) because Arduino is reset first (line 18). You can combine the above ku_reset function with the Time / Time Alarm library to make the Arduino auto-reset system periodically for a period of time, e.g. once a week or once a month to refresh your Arduino system.

Trial and error

Arduino Uno is able to indentify its own condition especially in the term of “hang/crash” or crash. Arduino must be able to detect itself not working properly and how to handle it. One of the most widely used ways is to use WDT (watchdog timer). , I.e. a kind of overflow timer will trigger an interrupt that will reset a processor (in this case AVR ATMega microcontroller in Arduino board).

So the Arduino reset technique with WDT is different from the reset method using the ku_reset function above. If using WDT, the reset system will be triggered by the WDT timer overflow, if using the ku_reset function, the reset system will occur because we call the function. So WDT is an Arduino reset mechanism if it hangs/crashes (post-events), whereas the ku_reset function is the Arduino reset mechanism before it hangs/crashes (preventive). You may find error in your first attempt on this Arduino uno tutorial, it is okay; it will not affect the previous condition of the board and its systems.