Its pretty easy once you get started, the starting from the example Mark posted, the Analog get returns the value of the potentiometer as a voltage, you can start making
this.
You should change the .5 to whatever value you want the motor to run at, and the 2.4 and 2.5 to where you want the motor to stop at which value on the potentiometer, you should also change the way this is done once you get used to PID controls, as this is a really mediocre way to code this, but it works as a proof of concept.