 volatile uint16_t throttleInValue;
 
 //Stores the pin number for each receiver input
-int aileronInPin = -1;
-int cutoverInPin = -1;
-int elevatorInPin = -1;
-int rudderInPin = -1;
-int throttleInPin = -1;
+byte aileronInPin = 255;
+byte cutoverInPin = 255;
+byte elevatorInPin = 255;
+byte rudderInPin = 255;
+byte throttleInPin = 255;
+
+//Stores the servo range of the throttle
+byte aileronMax = SERVO_MAX;
+byte aileronMin = SERVO_MIN;
+byte elevatorMax = SERVO_MAX;
+byte elevatorMin = SERVO_MIN;
+byte rudderMax = SERVO_MAX;
+byte rudderMin = SERVO_MIN;
+byte throttleMax = SERVO_MAX;
+byte throttleMin = SERVO_MIN;
 
 //Determines if the servos are in the process of calibration
 boolean calibrationMode = false;

//Sends all calibrated receiver input max and min values as JSON over the serial interface
void sendCalibrationJsonData() {
  StaticJsonBuffer<CHAR_ARRAY_SIZE> jsonBuffer;
  JsonObject& root = jsonBuffer.createObject();
  JsonObject &calibrationData = jsonBuffer.createObject();;
  calibrationData["aileronMin"] = aileronMin;
  calibrationData["aileronMax"] = aileronMax;
  calibrationData["elevatorMin"] = elevatorMin;
  calibrationData["elevatorMax"] = elevatorMax;
  calibrationData["rudderMin"] = rudderMin;
  calibrationData["rudderMax"] = rudderMax;
  calibrationData["throttleMin"] = throttleMin;
  calibrationData["throttleMax"] = throttleMax;
  calibrationData["cutoverMin"] = cutoverMin;
  calibrationData["cutoverMax"] = cutoverMax;
  root["calibrationData"] = calibrationData;
  Serial.print(startMarker);
  root.printTo(Serial);
  Serial.println(endMarker);

        manualControl = (boolean) root["manualControl"];
        sendJson("manualControl", manualControl);
      } else {
        sendJson("error", "Calibration required");
      }
    }

    //Enable or disable calibration mode
    if (root.containsKey("calibrationMode")) {
      if (!manualControl) {
        calibrationMode = (boolean) root["calibrationMode"];
        sendJson("calibrationMode", calibrationMode);
        if (calibrationMode) {
          resetCalibration();
        } else {
          if (calibrationComplete()) isCalibrated = true;
          sendCalibrationJsonData();
        }
      } else {
        sendJson("error", "Disable manual control");
      }
    }

