readStringUntil()

Parent Previous Next

시리얼 수신 버퍼에 있는 데이터를 읽고 종료 문자를 감지하거나  Timeout 발생 시  읽은 데이터를 String 형태로 리턴합니다.



사용방법

Serial.readStringUntil(terminator)



terminator : 감지할 종료 문자 (char)


리턴값

String - 읽은 데이터


예제 코드

void setup() {

  Serial.begin(9600);      

}


void loop() {  


 if(Serial.available())

 {

   //데이터를 String으로 읽고 종료 문자를 Carriage return으로 설정

   String s = Serial.readStringUntil('\r');

   Serial.println(s);

 }

}

Created with the Personal Edition of HelpNDoc: Generate Kindle eBooks with ease