Controlling a Servo with an IR Distance Sensor

Hello, I am attempting to create a small car that is able to detect the distance in front of it so that it can run when there is no reading, but stop, turn, and try forward again when there is. I have been simply trying to control the servo with the IR sensor, but it does not respond as it should. The servo does not stop when the value reads higher than 940.

Simple_IR.ino (484 Bytes)