我遇到问题让我的功能继续执行if(Status ==" True")声明,但我不确定原因。当我打印他们似乎匹配的线条。我还包括了一个串行输出的样本。
B' RCSSTATUS \ r \ n' B'假\ r \ n' B' RCSSTATUS \ r \ n' B'假\ r \ n' B' RCSSTATUS \ r \ n' B'假\ r \ n'
com = command = DATASET =' RCSSTATUS' +结果+' \ n' =真
void parseCommand(String com){
String Action;
String Status;
Action = com.substring(0, com.indexOf(" "));
Status = com.substring(9, com.indexOf("e") + 1);
Serial.println(Action);
if(Action == "RCSSTATUS")
{Serial.println(Status);
if(Status == "True"){
digitalWrite(5, HIGH);
digitalWrite(4, LOW);
}
if(Status == "False"){
digitalWrite(6, HIGH);
digitalWrite(4, HIGH);
digitalWrite(5, LOW);
}}}
答案 0 :(得分:0)
我明白了。我的输出字符串在行的开头有一个空格。将if(Status == "True")
更改为if(Status == " True")