아두이노

아두이노 reset -#3

오징어땅콩2 2020. 1. 27. 15:16
반응형

이 방법도 소프트웨어적인 방법이다.

그래도 시발점, 트리거를 위해서 2번핀에 풀다운 버턴을 하나 달았다.

소스코드에서 함수를 호출 한다.

 

딜레이를 준이유는 직접하면 알겠지만, 한번 누르면 여러번 리셋된다. 

그것을 방지하기 위한것이고, 리셋하는 함수는 실제로 한줄이다.

큰 어려움은 없을것  같다.

 

#define BAUD 115200
void (*reset_fun) (void= 0;
void setup() 
{
    Serial.begin(BAUD);   
    pinMode(2,  INPUT);
    Serial.print("ARDUINO RESET TEST!!! \n");
}
 
void loop() 
{
  int v1= digitalRead(2);
  if(v1== HIGH) software_reset();
}
 
void software_reset()
{
    Serial.print("RESET \n");
    delay(1000);
    reset_fun();
    Serial.print("NOTHING!!! \n");
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter