   int error = -1; // Set to first laser we can't calibrate.
   for (int i = 0; i < inputCount; ++i) {
     thresholds[i] = (minLasersOn[i] + maxLasersOff[i]) / 2;
-    Serial.print(i);
+    Serial.print(i+1);
     Serial.print(": ");
     Serial.print(thresholds[i]);
     
     if (minLasersOn[i] - maxLasersOff[i] < minCalibrationGap) {
+      thresholds[i] = -1;
       Serial.print("  CALIBRATION FAILED!");
       if (error == -1)
         error = i;

}

const long heartbeat = 1000;  // milliseconds between heartbeats.
void loop() {
    long lastTimeHeartbeat, currentTime;
    
    updateLed();
    
    currentTime = millis();
    if (currentTime - lastTimeHeartbeat > heartbeat) {
      lastTimeHeartbeat = currentTime;
      Serial.println('~');
    }

    for (int i = 0; i < inputCount; ++i) {
      
        // Read analog input value.
        int value = multiplexedAnalogRead(i);
        

        // If different than last value, send notification.
        if (newInput != current[i]) {
            if (newInput)
              Serial.write('a' + i); // HIGH means laser detected -> interruption OFF
            else
              Serial.write('A' + i); // LOW means laser not detected -> interruption ON
         }
        current[i] = newInput;
    }  
