How to adjust position of servo exactly when controlled by pot!!

I follow the example ( servo controlled by potentiometer)
In the example, we just take analog value from potentiometer and process it by map function. Although it may be a stupid question, I would like to ask everyone : Does servo rotate exactly to the position after map function:
Here demo code:

Servo myservo;  // create servo object to control a servo

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

void setup() {
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() {
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023)
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180)
  myservo.write(val);                  // sets the servo position according to the scaled value
  delay(15);                           // waits for the servo to get there
}

In demo code, they require potentiometer 10k, but if I use 5k , does it affects to the result ( position)
Please share your wisdom.
Sincere thanks

Does servo rotate exactly to the position after map function:

The value passed to the Servo.write() method is mapped to a duration, and sent to the servo using writeMicroseconds(). There will be some loss of accuracy when the mapping occurs. For hobby servos, that loss hardly matters since hobby servos are not all that accurate anyway.

In demo code, they require potentiometer 10k, but if I use 5k , does it affects to the result

You could have printed out the result of the map() operation, and answered your own question.

PaulS: The value passed to the Servo.write() method is mapped to a duration, and sent to the servo using writeMicroseconds(). There will be some loss of accuracy when the mapping occurs. For hobby servos, that loss hardly matters since hobby servos are not all that accurate anyway.

Thanks. 1/ Do you have any suggestion to adjust position servo more correctly. 2/ When I put knob ( potentiometer at 0V and 5v), the servo is vibrating. I dont know that the problem is and how to solve it

If the potentiometers are mechanically similar and both linear, 10K to 5K will not make any difference for positioning. You could run a test like here: https://www.youtube.com/watch?v=f5klLiTm1Rs

2/ When I put knob ( potentiometer at 0V and 5v), the servo is vibrating. I dont know that the problem is and how to solve it

Could be the usual poor power supply or bad grounding, or a sloppy pot. You might try using microseconds instead of degrees like below.

  val = map(val, 0, 1023, 600, 2400);    
  myservo.writeMicroseconds(val);

You may be hitting the servo’s end stops, try starting at 40 degrees and “sneaking” down toward zero to see if it goes all the way without binding, do the same from 150 to 180.
Also, try this sketch to test them individually. Type a number from 0 to 180 or 550 to 2450 in the top of the serial monitor and hit .

#include <Servo.h>
Servo servo;


const int angle = 0;

void setup() {
  // initialize serial:
  Serial.begin(9600);
  servo.write(1544);
  servo.attach(9);
  for(int i = 0;i < 180;i++){
    servo.write(i);
    delay(3);
  }

  Serial.println(servo.readMicroseconds());
  for(int i = 180;i >= 0;i--){
    servo.write(i);
    delay(3);
  }
  Serial.println(servo.readMicroseconds());  
}

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:
    int angle = Serial.parseInt(); 
    // look for the newline. That's the end of your
    // sentence:
    if (Serial.read() == '\n') {
    }
    servo.write(angle);
    Serial.print(angle);Serial.print("\t");
    Serial.println(servo.readMicroseconds());

  }
}

zoomkat: Could be the usual poor power supply or bad grounding, or a sloppy pot. You might try using microseconds instead of degrees like below.

  val = map(val, 0, 1023, 600, 2400);    
  myservo.writeMicroseconds(val);

I realize that in the servo.write library the maximum and minimum PWM are set as 2400 and 544 respectively. Now I am using servo MG996R, maybe the PWM in servo library is greater than PWM range of MG996R

Now I am using servo MG996R, maybe the PWM in servo library is greater than PWM range of MG996R

The maximum and minimum values can be overridden in the constructor. Experiment with larger and smaller values, to see what YOUR limits are.

And, answer the question about how you are powering the servo.