Servo control with lpc1768

I NEED HELP

Im trying to control a servo using an analog input from a 10k potentiometer, how would i go about this? the servo gets all twitchy and lags. What would be a sample code for this?