bi-directional stepper control w/ pot

so I built the adafruit motorshield
and its all working running this test code:

#include <AFMotor.h>

AF_Stepper motor(200, 1);  // set up motor specs

void setup() {
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");

  motor.setSpeed(70);  // set motor speed to 10 rpm
}

and I am using a 10K variable resistor

so reading the value from the analog pin will produce 1024 possible values

my stepper motor requires 200 steps to complete 1 revolution

the motor is going to open and close a turbo actuator, and from fully open to fully closed it requires about 9 revolutions of the motor shaft.

and I want the pot to control the position of the actuator, so as the reading on the analog pin the stepper steps forward, and if the value decreases the stepper steps back.

I plan to add two microswitches to act as feedback "stops" on either end of the actuator travel, but for now I am having trouble envisioning this code

should I build a linear relationship stepped "map"
that basically says..

pairs up a set of analog pin values with a stepper position
and based on the values from the last loop moved the stepper backward or forward. This method is going to be very sawtoothed
but will allow me to change the "curve" of the actuator action
weighting the bottom end of the scale or the middle etc..

or can a algorithm be written that evaluates all 1024 values for analogRead and moves the stepper within the pre-defined range:
9 complete revolutions (1800 steps) from open to close or 1.757 steps for every value read from analogRead

I have been searching for hours thru the forums trying to find a starting point.. :o

Thanks !!

so I have normalized the input with map

int val = analogRead(0);   // init val to 0
  val = map(val, 0, 1023, 0, 1800);
  Serial.println(val);
  delay(50);

so analogRead values can correspond to motor steps

so this is where I am now, but something is not right...
am I stepping on a variable somewhere ?

#include <AFMotor.h>

AF_Stepper motor(200, 1);  // set up motor specs

int vnt = 1800; 

void setup() {

  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Stepper test!");

  motor.setSpeed(70);  // set motor speed to 10 rpm   
}

void loop() {
  int pot = analogRead(0);   // read pot value
  pot = map(pot, 0, 1023, 0, 1800);    // map 0-1024 to 0-1800
  Serial.println("startloop");
  Serial.println("VNT value is");
  Serial.println(vnt);
  Serial.println("pot value is");
  Serial.println(pot);

if (pot < vnt)
{
  int stepback = (vnt - pot);
//  motor.step(stepback, BACKWARD, DOUBLE);
  Serial.println("moving backwards");
  Serial.println(stepback);
  Serial.println("");
  vnt = stepback;
  delay(1500);
}

else if (pot > vnt)
{
  int stepforward = (pot - vnt);
//  motor.step(stepforward, FORWARD, DOUBLE);
  Serial.println("moving forward");
  Serial.println(stepforward);
  Serial.println("");
  vnt = stepforward;
  delay(1500);
}

else
{
  Serial.println("no change.. pot value is");
  Serial.println(pot);
  Serial.println("");
  delay(1500);
}



}

but something is not right

That's not a very helpful description of what's wrong.

it does not seem to be doing the math right...

when it hits the first case statement, it continues to subtract until zero
the second, adds until 1800 then loops..

hard to explain.. Ill get some serial output and post it..

when it hits the first case statement

I don't see a case statement - are you sure you're posting the right code?