embeded/arduino(genuino)2025. 10. 9. 22:44

예제로 맨날 폴링만 보다보니 인터럽트가 될거라 생각을 못했네..

/*
  SerialEvent occurs whenever a new data comes in the hardware serial RX. This
  routine is run between each time loop() runs, so using delay inside loop can
  delay response. Multiple bytes of data may be available.
*/
void serialEvent() {
  while (Serial.available()) {
    // get the new byte:
    char inChar = (char)Serial.read();
    // add it to the inputString:
    inputString += inChar;
    // if the incoming character is a newline, set a flag so the main loop can
    // do something about it:
    if (inChar == '\n') {
      stringComplete = true;
    }
  }
}

 

[링크 : https://docs.arduino.cc/built-in-examples/communication/SerialEvent]

[링크 : https://juahnpop.tistory.com/85]

[링크 : https://m.blog.naver.com/dhtpals32123/222270427302]

'embeded > arduino(genuino)' 카테고리의 다른 글

arduino nano로 4채널 pwm 출력하기  (0) 2025.10.11
퀄컴 아두이노 인수  (0) 2025.10.08
아두이노 sd 카드  (0) 2025.08.24
skt-444 콘덴서 마이크 모듈 분해  (0) 2025.08.07
HW-504 이상해..  (0) 2025.08.02
Posted by 구차니