Serial.read to interger

Hey everyone, at the moment I'm working on a project which includes HC-05 module and a servo.

The goal is to send(using a phone) a number of degrees(0-180) that the servo must turn.

#include<Servo.h>
Servo servo;
String servoDegrees;
char number;

void setup() {
servo.attach(8);
Serial.begin(9600);
servo.write(0);
}
void GetTheNumberAndRotate(){  
  if(Serial.available()){
  while(Serial.available()>0){
   number=Serial.read();
   servoDegrees+=number;
   }
   Serial.println(servoDegrees);
   servo.write(servoDegrees.toInt());
  }
  
  
}

void loop() {
GetTheNumberAndRotate();
  

}

The problem I'm facing is that I can't properly read from the Serial. It seems like the while loop is running only once, no matter the number I put in. As I've read in the internet the method Serial.available() should return an interger which indicates the number of characters that have been inputted(IF that's wrong, please, correct me), so if I input the number 123 the while loop should be repeated 3 times(Right?)

Because of this problem I cannot rotate the servo more than once, because if I do the 2 numbers joins together(E.G. 1st-123 and 2nd-78, the output of the 2nd is 12378)

I could clean the "servoDegrees" before inputing a new number. But the thing is that in order to get the first number the "void loop" has tu run 3 times(if the number is made out of 3 digits).

All in all I think what I need the most is to properly understand how Serial.available() and Serial.read() works

If anyone could help I'd be grateful.

Also if I forgot to mention something please tell me, I'll try to be as useful as posiblle

The serial input basics tutorial might help you to understand how to receive and parse serial data.

Pradedantysis:
All in all I think what I need the most is to properly understand how Serial.available() and Serial.read() works

1. This is (Fig-1) is the view of Serial Monitor which contains an InputBox into which we will enter digits that correspond to 'degrees of rotation' of the servo.
SerialMonitor.png
Figure-1:

2. This is the sketch that will be uploaded into UNO to understand the meanings of these methods: available() and read().

#include<Servo.h>
Servo servo;
char number[4]="";

void setup()
{
  Serial.begin(9600);
  servo.attach(8);
  servo.write(0);
}
void loop()
{
  byte n = Serial.available();
  if (n == 3)
  {
    for (int i = 0; i < 3; i++)
    {
      number[i] = Serial.read();
    }
    Serial.print(number);  //shows the received digits
    int x = atoi(number);  //convert ASCII to integer
    Serial.print(',');
    Serial.println(x, DEC);  //shows integer valuse
    servo.write(x);
    memset(number, 0x00, 4);  //array is cleared
  }
}

3. Upload the sketch of Step-2.

4. Bring in the Serial Monitor at 9600 Baud Rate. Select 'Line ending tab' at 'No line ending'.

5. Enter 123 in the InputBox of Serial Monitor and then click on the Send button. Check that the shaft of the servo has rotated by 123 degrees.

Studies:
(1) When we have entered 123 and then clicked on the Send button, these codes (called ASCII Codes of digit 1, digit 2, and digit 3) : 0x31, 0x32, and 0x33 have traveled towards UNO one after another. These data bytes/characters are received by UNO, and they are saved in an unseen FIFO type Buffer. The UNO has received 3 data bytes and this number (3) has been reflected in the variable n of the following instruction:

byte n = Serial.available();

(2) We need to extract the number 123 from the received bytes (0x31, 0x32, 0x33); therefore, these data bytes must be brought out from the Buffer and then keep them into user variable which is this array: char number[4]. Serial.read() is the method that is used for this purpose and accordingly, we have executed the following codes where n indicates the number of data bytes to bring out from Buffer.

for (int i = 0; i < n; i++)
{
   number[i] = Serial.read();
}

(3) After that, we have used the atoi() method to convert the ASCII codes (0x31, 0x32, 0x33) into the equivalent integer number, 123.

SerialMonitor.png

As I've read in the internet the method Serial.available() should return an interger which indicates the number of characters that have been inputted(IF that's wrong, please, correct me), so if I input the number 123 the while loop should be repeated 3 times(Right?)

No, it will tell you how many bytes were received at the moment that available() was called. It might be that only 2 characters were completely received and the 3rd one was not completely received yet.