void setup()
{
Serial.begin(9600);
}
void loop()
{
if(Serial.available()){
int x, y;
x = Serial.parseInt();
delay(1000);
y = Serial.parseInt();
Serial.print(x);
Serial.print(y);
}
}
Code language: C++ (cpp)
Serial.available() : 시리얼의 버퍼 내 데이터의 길이를 바이트 단위로 알 수 있다.
Serial.parseInt() : 시리얼 버퍼 안에 있는 값을 정수형으로 인식하겠다.