Servo requires additionional digit

Hi guys, I'm doing a project in which I use the serial monitor to tell the servo what degree i want it at. It works fines except that it doesn't register the first digit that I write (for example, if I want it to go to 180 degrees, i have to write 1180 and if i want it to go to 90 degrees i need to write 990). Anyone have any idea why this is happening. This is my code, bellow, there's a bunch of stuff that has nothing to do with servos so I'm sorry about that

#include <Servo.h>
Servo servo1;
long num1;

void setup() {

//Setup Channel A
pinMode(12, OUTPUT); //Initiates Motor Channel A pin
pinMode(9, OUTPUT); //Initiates Brake Channel A pin

//Setup Channel B
pinMode(13, OUTPUT); //Initiates Motor Channel A pin
pinMode(8, OUTPUT); //Initiates Brake Channel A pin

//Setup for Servo 1
servo1.attach(10);
Serial.begin(9600);
}

void loop()
{

while(Serial.available())
{
char In=Serial.read();

if(In=='w' || In=='W') // Forward @ full speed
{
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(9, LOW); //Disengage the Brake for Channel A
digitalWrite(8, LOW); //Disengage the Brake for Channel B
analogWrite(3, 255); //Spins the motor on Channel A at full speed
analogWrite(11, 255); //Spins the motor on Channel B at full speed
}
else if(In=='s' || In=='S') // Stop
{
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(9, HIGH); //Engages the Brake for Channel A
digitalWrite(8, HIGH); //Engages the Brake for Channel B
analogWrite(3, 0); //Spins the motor on Channel A at zero
analogWrite(11, 0); //Spins the motor on Channel B at zero
}
else if(In=='a' || In=='A') // Slow Left
{
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(9, LOW); //Disengages the Brake for Channel A
digitalWrite(8, LOW); //Disengages the Brake for Channel B
analogWrite(3, 0); //Spins the motor on Channel A at zero
analogWrite(11, 90); //Spins the motor on Channel B at 90
}
else if(In=='q' || In=='Q') // Fast Left
{
digitalWrite(12, LOW); //Establishes forward direction of Channel A
digitalWrite(13, HIGH); //Establishes backwards direction of Channel B
digitalWrite(9, LOW); //Disengages the Brake for Channel A
digitalWrite(8, LOW); //Disengages the Brake for Channel B
analogWrite(3, 90); //Spins the motor on Channel A at 90
analogWrite(11, 90); //Spins the motor on Channel B at zero
}
else if(In=='d' || In=='D') // Slow Right
{
digitalWrite(12, HIGH); //Establishes forward direction of Channel A
digitalWrite(13, HIGH); //Establishes forward direction of Channel B
digitalWrite(9, LOW); //Disengages the Brake for Channel A
digitalWrite(8, LOW); //Disengages the Brake for Channel B
analogWrite(3, 90); //Spins the motor on Channel A at 90
analogWrite(11, 0); //Spins the motor on Channel B at zero
}
else if(In=='e' || In=='E') // Fast Right
{
digitalWrite(12, HIGH); //Establishes backwards direction of Channel A
digitalWrite(13, LOW); //Establishes forward direction of Channel B
digitalWrite(9, LOW); //Disengages the Brake for Channel A
digitalWrite(8, LOW); //Disengages the Brake for Channel B
analogWrite(3, 90); //Spins the motor on Channel A at 90
analogWrite(11, 90); //Spins the motor on Channel B at 90
}
else if(In=='z' || In=='Z') // Backwards
{
digitalWrite(12, LOW); //Establishes forward direction of Channel A
digitalWrite(13, LOW); //Establishes forward direction of Channel B
digitalWrite(9, LOW); //Disengages the Brake for Channel A
digitalWrite(8, LOW); //Disengages the Brake for Channel B
analogWrite(3, 255); //Spins the motor on Channel A at fullspeed
analogWrite(11, 255); //Spins the motor on Channel B at fullspeed
}
num1= Serial.parseInt();
Serial.print(num1);
servo1.write(num1);
}
}

(deleted)

not sure what you mean, could you please explain?

Set your monitor to no line ending. You are printing the 0 parse int value from the new line or carriage return at the end of your value. If you change the Serial.print statement you can see what is going on.

//Serial.print(num1);
Serial.println(num1);

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data.

...R

(deleted)

colinjalbert1:
not sure what you mean, could you please explain?

Surely that was clear - you've read the first digit from the buffer before calling readInt() so it isn't there anymore.

You can use     char In=Serial.peek();
to see if the character is a letter command or a digit WITHOUT removing it from the input buffer. If it's a letter command, read it from the buffer when you process it. It's it's a digit, use .parseInt() to read the number.