Need help with controlling servo with Sharp distance sensor.

Here, I have arduino uno, micro servo, and a distance sensor. I connect the servo on pin 9 and the sensor on analog pin 0 (A0). I want to rotate the servo to 90 degrees when the distance sensor detecting. and if it does not detect the remains in a position of 0 degrees. how about source code ? please help me.

Try reading here to start, see how things are done.
http://forum.arduino.cc/index.php?topic=185476.0

I've tried the code. Servo keep rotate but sensor not detect'. :\

RIFarfa27:
I've tried the code. Servo keep rotate but sensor not detect'. :\

If you post your code here on this forum, perhaps we can help.