为什么这个引脚在命令 43 第一次进入时不触发?

Why does this pin not fire the first time the command 43 comes in?

我正在使用 Arduino 开发一个游戏结束计时器。基本上,程序从串口获取命令,翻转引脚,等待 5 秒,然后触发复位命令。它有效,但它并没有在“43”第一次出现时就这样做。它将第二次执行并在之后正常工作。这是为什么?我错过了什么?

#include <elapsedMillis.h>
elapsedMillis timeElapsed; 
int pin = 13;
unsigned int wait = 5000;

//// SERIAL //////////////////////////////////////////////
byte incomingByte; // from python
int command = 0; // command (1 = open, 2 = close)
int servoCom = 0; // the incoming command shit

void setup() 
{ 
  Serial.begin(9600);
  pinMode(pin, OUTPUT);
  digitalWrite(pin, LOW);
  Serial.println("setup done");

  // wait 20 ms
  delay(20);
}

void loop()
{
  if (Serial.available() > 0) 
  {
    incomingByte = Serial.read(); 
    command = incomingByte;
    servoCom = ServoGo(command);  
  }

  if (servoCom == 43){
    digitalWrite(pin, HIGH);
    // run for 5 seconds
    if (timeElapsed >= wait) 
    { 
      // trigger reset
      servoCom = 70;  
    }
  }
  if(servoCom == 70){
    // reset 
    digitalWrite(pin, LOW);
    timeElapsed = 0; 
  } 
}

int ServoGo(int com)
{
    Serial.println("!inServoGo");
    Serial.println(com);
    return com;
}

timeElapsed 在设置时未初始化为零;它在第一个命令 70 后重新初始化,然后只有命令 23 正常工作。