Control (DC Motor w/ Encoder) Position using a Potentiometer....

Basically I'm trying to make a servo motor out a DC motor that has an encoder. I'm wanting to make something like this: Potentiometer control DC Motor Position (DIY Servo) Using Arduino - YouTube

My parts:
Motor - Pololu - 30:1 Metal Gearmotor 37Dx52L mm 12V with 64 CPR Encoder (No End Cap) (My Project requires me to a DC motor)
Motor Driver - http://www.arduino.cc/en/Main/ArduinoMotorShieldR3
MCU is an UNO

I have not problem making the motor move with the POT. But I'm just not sure how to stop the motor fast at a given position. It runs past the stop point... I would love to be able to start from a source code that worked like the one in the video above.

This is the basic code that I'm using to just try and stop the motor as a test.. When it hits the end position it engages the brake, but still rolls past the stop points

#include <Encoder.h>
Encoder myEnc(2, 4);

int motorDir = 12;
int motorBrake = 9;
int motorSpeed = 3;
int sensorPin = A4; 

int positionEnd = 2000;

void setup() {
  pinMode(motorDir, OUTPUT); 
  pinMode(motorBrake, OUTPUT);
  Serial.begin(9600);

  digitalWrite(motorDir, LOW);  //Establishes forward direction 
  digitalWrite(motorBrake, LOW);   //Disengage the Brake 
  analogWrite(motorSpeed, 100);   //Motor speed

}

void loop() {


  if (myEnc.read() >= positionEnd ) {
    analogWrite(motorSpeed, 0);   //Motor speed
    digitalWrite(motorBrake, HIGH);   //Engage the Brake
    Serial.print("Brake ");
    Serial.println(myEnc.read());    //Echos current Postion

  }
}

Thanks for any help or suggestions!!!

    Serial.println(myEnc.read());    //Echos current Postion

But, that's not the same position that was used to determine whether to stop the motor.

What you need to do is to determine how far away from where you are now the motor should stop, and you should start slowing it down before just slamming on the brakes.

You need PID control. Imagine that the input pot is moved a long distance - you want the motor to move quickly to get near that position. Then when it's close to right, you want it to move slowly, so it has a chance of stopping on the correct point.

PID is proportional - it looks at the distance it needs to move as well as the speed since in this case you want to arrive at the commanded point with zero speed.

You can do this in your own code - calculate a motor command based on the simple distance between the commanded position and the actual position - or you can try a PID library. Personally, I think it will be easier to try the first approach before getting too confused with PID.