轉自: https://blog.csdn.net/y511374875/article/details/77845240html
三種方式手動重啓Arduinogit
1.Arduino板上從新編寫代碼時,Arduino將從新設置 2.Arduino軟件中打開串行終端,同時將Arduino板鏈接到計算機。打開串行終端時,Arduino會自動重置 3.按下復位按鈕編程
兩種方式自動重啓Arduino函數
詳情見: https://www.theengineeringprojects.com/2015/10/upload-bootloader-atmega328.htmloop
1.使用Arduino板上的RESET引腳以編程方式從新設置Arduino,就是利用一個數字口,代碼運行到那的時候就將REST置低 這裏利用數字口D2ui
int Reset = 2;this
void setup() { digitalWrite(Reset, HIGH); delay(200); pinMode(Reset, OUTPUT); Serial.begin(9600); Serial.println("How to Reset Arduino Programmatically"); delay(200); }.net
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.");code
}1234567891011121314151617181920212223htm
2.不使用任何硬件引腳,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.");