C ++运算符问题()

时间:2015-01-28 16:45:35

标签: c++ arduino

Arduino scetch的Theres问题 它的代码部分:

![void verifica(){
    msg=msg.substring(1,13);
    if(ID.indexOf(msg)>=0) Serial.println("Access granted.");
    {
      digitalWrite(10, HIGH);
      delay(2000);
      digitalWrite(10, LOW);
    }
    else Serial.println("Access denied.");
    {
      digitalWrite(9, HIGH);
      delay(2000);
      digitalWrite(9, LOW);
    }
}

所以我编译时遇到了麻烦,看起来没有失败。对不起,是的,我n00b =( http://s019.radikal.ru/i608/1501/5e/db7c7db4380b.png

1 个答案:

答案 0 :(得分:3)

您已收到else但未附加if

据推测,println应该在下面的块中,而不是if语句的整个主体:

if(ID.indexOf(msg)>=0)
{
  Serial.println("Access granted.");  // <<< inside if body
  digitalWrite(10, HIGH);
  delay(2000);
  digitalWrite(10, LOW);
}
else
{
  Serial.println("Access denied.");   // <<< inside else body
  digitalWrite(9, HIGH);
  delay(2000);
  digitalWrite(9, LOW);
}