You will need to post a schematic.
Also, you will need to post code snippets for what you're trying to do.
To help with troubleshooting, try doing just one thing. For example, try reading the sensor, and turn on/off a LED with it. Make sure you can get that to work.
Then, try turning the servo back and forth with a delay, without any sensors. Make sur eyou can get that to work.
Then, combine the two.