除了重新烧录代码和按下复位键的方法外,Arduino还自带重置函数:
不使用任何硬件引脚,Arduino有一个名为resetFunc()的内置函数,我们声明函数地址为0,当我们执行此功能时,Arduino将自动重置。
说明: –In this method, we are not gonna use any hardware pin, instead we will do everything in programming. –Arduino has a builtin function named as resetFunc() which we need to declare at address 0 and when we execute this function Arduino gets reset automatically. –So, no need of doing anything in hardware and simply upload the below code in your Arduino board.
void(* resetFunc) (void) = 0;
void setup() { Serial.begin(9600); Serial.println("How to Reset Arduino Programmatically"); 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.");
参考连接:https://blog.csdn.net/weixin_30399821/article/details/96811509