私は Arduino プロジェクトに取り組んでおりSerial port
、arduino シリアル イベントで からいくつかのコマンドを受け取りたいと考えています。ただし、常に条件を満たさないため、コードはシリアル イベントが終了したことを認識できません。これが私のコードです。
void serialEvent() {
while (Serial.available()) {
// get the new byte:
char inChar = (char)Serial.read();
if (inChar == '`')
{
// 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 == '|') {
settingsReceived = true; // <----- This will never be called
Serial.println("true"); // <------ Nor this will too
}
}
}
}
シリアル モニタから文字列を渡そうとしました`Hello|
が、応答しません。Line ending
さらに、 withNo Line Ending
を試しましたが、うまくNewline
いきません。誰か助けてください。ありがとう!