If you have worked on any Arduino board, then you must have noticed the RESET pin in Arduino and you may wonder what's the use of this pin. So, today this pin is gonna get useful. Moreover, you have also noticed that when you upload the code to your Arduino board then the Arduino resets, another way of resetting Arduino is by opening the Serial Terminal in Arduino software, while connecting your Arduino board to your computer. As you open the Serial Terminal, the Arduino automatically gets reset. The third way of resetting Arduino is by pressing the push button. When you press and release the push button, Arduino gets reset. You should also have a look at How to get Hex File from Arduino.
So till now we have seen three ways of resetting Arduino but you have noticed that all of these methods are manual, you have to manually push the button or to open the Serial Terminal or to upload the code. Now in some projects, we have to reset Arduino Programmatically, like we don't do anything and it just reset itself automatically. Now how can we do that, that's the topic of today's tutorial. So, I am gonna share two methods today using which we are gonna reset Arduino programmatically. So, let's start with them.
Where To Buy? | ||||
---|---|---|---|---|
No. | Components | Distributor | Link To Buy | |
1 | Jumper Wires | Amazon | Buy Now | |
2 | Arduino Uno | Amazon | Buy Now |
int Reset = 4; void setup() { digitalWrite(Reset, HIGH); delay(200); pinMode(Reset, OUTPUT); Serial.begin(9600); Serial.println("How to Reset Arduino Programmatically"); Serial.println("www.TheEngineeringProjects.com"); delay(200); } void loop() { Serial.println("A"); delay(1000); Serial.println("B"); delay(1000); Serial.println("Now we are Resetting Arduino Programmatically"); Serial.println(); delay(1000); digitalWrite(Reset, LOW); Serial.println("Arduino will never reach there."); }
void(* resetFunc) (void) = 0; void setup() { Serial.begin(9600); Serial.println("How to Reset Arduino Programmatically"); Serial.println("www.TheEngineeringProjects.com"); delay(200); } void loop() { Serial.println("A"); delay(1000); Serial.println("B"); delay(1000); Serial.println("Now we are Resetting Arduino Programmatically"); Serial.println(); delay(1000); resetFunc(); Serial.println("Arrduino will never reach there."); }
JLCPCB – Prototype 10 PCBs for $2 (For Any Color)
China’s Largest PCB Prototype Enterprise, 600,000+ Customers & 10,000+ Online Orders Daily
How to Get PCB Cash Coupon from JLCPCB: https://bit.ly/2GMCH9w