   // send command packet to RDM880
   RDM880.write(get_readID, 8);
   delay(100);
-  digitalWrite(ledPin, LOW); 
+  digitalWrite(ledPin, LOW);
+  response[7] = NULL;
   standby = true;
-  response[7] = NULL;
-  elapsed_time = 0;
 
   // read response from RDM880 and print
   int i = 0;

    }
    // check for OFF signal
    else if (previousState == HIGH && signalState == LOW) {
      endTime = millis();
      // calculate elapsed time
      return endTime - startTime;
    }
    // no event
    else {
      previousState = signalState;
    }
  }
  return 0;
}



  int signalState;
  int previousState = NULL;
  
  while(standby == false) {
    // read signal state
    signalState = digitalRead(signalPin);

