Servo motor with a ultrasonic sensor

I do not know what you mean there and the code does not give me a clue. Please explain, in detail, how the servo should react to the distance measured by the rangefinder. Should the servo indicate the range like a needle on a gauge? What are the extremes (closest, farthest) to measure and indicate?