Modify Arduino Code to move servo

hello everyone, i was following a tutorial for servo android control and wanted to modify the arduino code with no idea where to start

  #include <Servo.h>

Servo myservo;  // create servo object to control a servo
                // a maximum of eight servo objects can be created

int pos = 0;    // variable to store the servo position
int motor = 0;

void setup()
{  
  Serial.begin(9600);  // initialize serial: 
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
 
  Serial.print("Arduino control Servo Motor Connected OK");
  Serial.print('\n');
}

void loop()
{ 
  // if there's any serial available, read it:
  while (Serial.available() > 0) {
    
    // look for the next valid integer in the incoming serial stream:
    //motor = Serial.parseInt();
   
    // do it again:
    pos = Serial.parseInt();
  
    // look for the newline. That's the end of your  sentence:
    if (Serial.read() == '\n') {
              
       myservo.write(pos);              // tell servo to go to position in variable 'pos'
       delay(15);                       // waits 15ms for the servo to reach the position
     
      // print the three numbers in one string as hexadecimal:
      Serial.print("Data Response : ");
      //Serial.print(motor, DEC);
      Serial.print(pos, DEC);
      
    }
  }
}

This code will when executed set my servo to a degree of 180, and stay locked. if i tried to move it with my fingers it wont budge, only when i send an angle will it move.

What i wanted for it to do is, while input is not being send to the servo, the servo as free motion meaning if i moved it with my fingers it would move. Once i send an angle however, it stays locked to that degree for x amount of seconds then has free motion again.

Thanks!

What i wanted for it to do is, while input is not being send to the servo, the servo as free motion meaning if i moved it with my fingers it would move. Once i send an angle however, it stays locked to that degree for x amount of seconds then has free motion again.

Heres an experiment. Unplug the servo so that it has absolutely no power. Try to move it with your finger and see if it has "free motion". Tell us the results.

You need to look into using millis() for timing as in the BlinkWithoutDelay example and Several things at the same time

Save the time of the servo move then each time through loop() check whether the required period has elapsed since the move. If not then go round loop() again reading inputs etc. If the period has elapsed then detach the servo to allow it to move freely. Don't forget to attach it again before the servo.write() to make it move to a new position.

This supposes that the servo can move freely when power is supplied but no control signal is present.