How to control the speed of rotation of a servo using a potentiometer?
"Servo freaks out and starts twitching in one spot."


Check your connections to the servo, this sounds like an issue I had in my starting grad years: unshared GND. If you are using an external source to power the servo, the external source GND should be connected to the GND of the microcontroller. Otherwise, your servo control signal will not be referenced appropriately and will lead to "undefined behavior" in the form of twitching.