これです。
------------------------------------
String inData;void setup() {
Serial.begin(9600);
Serial.println("Serial conection started, waiting for instructions...");
}
void loop() {
while (Serial.available() > 0)
{
char recieved = Serial.read();
inData += recieved;
// Process message when new line character is recieved
if (recieved == '\n')
{
Serial.print("Arduino Received: ");
Serial.print(inData);
if(inData == "+++\n"){ // DON'T forget to add "\n" at the end of the string.
Serial.println("OK. Press h for help.");
}
inData = ""; // Clear recieved buffer
}
}
}
-----------------------------------
https://www.it-swarm.dev/ja/arduino/arduino%E3%82%92%E4%BD%BF%E7%94%A8%E3%81%97%E3%81%A6serialread%EF%BC%88%EF%BC%89%E3%82%92%E4%BD%BF%E7%94%A8%E5%8F%AF%E8%83%BD%E3%81%AA%E6%96%87%E5%AD%97%E5%88%97%E3%81%AB%E5%A4%89%E6%8F%9B%E3%81%97%E3%81%BE%E3%81%99%E3%81%8B%EF%BC%9F/971335319/
0 件のコメント:
コメントを投稿