int input = Serial.parseInt(); // keep other operations outside the constrain function int constrainedInput = constrain(input, minimumValue, maximumValue);