Help! Serial Monitor double printing and wrong data!

So I am trying to make a program on my Arduino nano in order to control some servos with directly complementary angles. the servos are irrelevant at the moment since that code will come later. Right now, I type in the number of the dominant servo, and it spits back the number I inputted and the number which corresponds to it. The problem is after the delay, it spits back the initially defined variables, and I don’t know how to stop it from putting anything out other than the two numbers that are complimentary for the angles? Please help!!! all of my programs up until now always double-run the Serial monitor, so any tips and tricks would be greatly appreciated!

AlternateServoAnglesc.ino (765 Bytes)

What have you got Line Ending set to in the Serial monitor ?
Try setting it to "No line ending"

UKHeliBob:
What have you got Line Ending set to in the Serial monitor ?
Try setting it to "No line ending"

it Worked!!!! Eureka!!!

Do you understand what the problem was ?

UKHeliBob:
Do you understand what the problem was ?

No, Why was it double printing?

 while (Serial.available()==0){
}

Waits for Serial data to become available
Then

 servoAngle = Serial.parseInt();

reads an int into the ServoAngle variable. If no integer is found then, after a timeout of 1 second the code moves on

By having a line ending turned on then there is still data in the Serial buffer after the parseInt(), available() returns > 0 so the input is read again, no int is found, the timeout occurs and the previous value is printed again