How to reset Arduino by programming
How can I reset Arduino using Arduino code?
Answer
There are two way to reset Arduino by coding: hardware reset and software reset
Hardware Reset Arduino by coding
- Connnect an Arduino digital pin to RESET pin

- Config the digital pin as a digital output pin by using pinMode() function.
- Program for the digital pin to LOW to reset Arduino by using digitalWrite() function.
/*
 * Created by ArduinoGetStarted.com
 *
 * This example code is in the public domain
 *
 * Tutorial page: https://arduinogetstarted.com/faq/how-to-reset-arduino-by-programming
 */
const int OUTPUT_PIN = 2;
void setup() {  
  digitalWrite(OUTPUT_PIN, HIGH);
  pinMode(OUTPUT_PIN, OUTPUT);     
  Serial.begin(9600);
  Serial.println("How to Reset Arduino Programmatically");
}
void loop() 
{     
  Serial.println("Arduino will be reset after 5 seconds");
  delay(5000);
  digitalWrite(OUTPUT_PIN, LOW);
  Serial.println("Arduino never run to this line");
}
Software Reset Arduino by coding
- Declare the reset function
void(* resetFunc) (void) = 0;  // declare reset fuction at address 0
- Call the reset function when needed
resetFunc(); //call reset
Buy Arduino
| 1 × Arduino UNO Buy on Amazon | |
| 1 × USB 2.0 cable type A/B Buy on Amazon | 
Disclosure: Some links in this section are Amazon affiliate links. If you make a purchase through these links, we may earn a commission at no extra cost to you.
Additionally, some links direct to products from our own brand, DIYables .
Additionally, some links direct to products from our own brand, DIYables .