Controlling a stepper with a pot

I want to map a stepper to a pot. However, i'm having a little trouble figuring out where to start...

I'm using a nema-17 200 step motor with an adafruit motor shield and the AFMotor library.

Hi, Here's an example (for different motors) that controls two motors. THis is for a demo we run that has two modes: Automatic runs both motors opposite directions, accelerates etc. Manual has 2 pots. The motors move (slowly) to the pot position. YMMV. Hopefully some ideas..

/* YourDuinoStarter Example: 2 Stepper Motors
 - WHAT IT DOES: Runs 2 28BYJ-48 stepper motors with AccelStepper Library
 - Motors accelerate and decelerate simultaneously in opposite rotations
 - SEE the comments after "//" on each line below
 -  Derived from example code by Mike McCauley
 -  modified by Celem for single stepper
 -  modified by lowres for two steppers
 - V1.01 11/30/2013
   Questions: terry@yourduino.com */

/*-----( Import needed libraries )-----*/
// AccelStepper library from: http://www.airspayce.com/mikem/arduino/AccelStepper/
#include <AccelStepper.h>
/*-----( Declare Constants and Pin Numbers )-----*/
#define FULLSTEP 4
#define HALFSTEP 8
// motor pins
#define motorPin1  2	// Blue   - 28BYJ48 pin 1
#define motorPin2  3	// Pink   - 28BYJ48 pin 2
#define motorPin3  4	// Yellow - 28BYJ48 pin 3
#define motorPin4  5	// Orange - 28BYJ48 pin 4
// Red    - 28BYJ48 pin 5 (VCC)

#define motorPin5  6	// Blue   - 28BYJ48 pin 1
#define motorPin6  7	// Pink   - 28BYJ48 pin 2
#define motorPin7  8	// Yellow - 28BYJ48 pin 3
#define motorPin8  9	// Orange - 28BYJ48 pin 4
// Red    - 28BYJ48 pin 5 (VCC)

#define PotLeftMotorPin  A0  // For manual control
#define PotRightMotorPin A1

#define ModeSwitchPin    11  

#define  AutoMode    1      // Define Auto or manual mode
#define  ManualMode  0

/*-----( Declare objects )-----*/
// NOTE: The sequence 1-3-2-4 is required for proper sequencing of 28BYJ48
AccelStepper stepper1(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);
AccelStepper stepper2(HALFSTEP, motorPin5, motorPin7, motorPin6, motorPin8);

/*-----( Declare Variables )-----*/
int  RunMode;    //Set Auto or Manual
int  StartAutoModeOnce;   // Do setup for Auto Mode
int  StartManualModeOnce; // Do setup for Auto Mode

int  LeftPotValue;  // Read from the manual potentiometerrs
int  RightPotValue;

long int LeftMotorTarget   ;
long int RightMotorTarget   ;

int  ModeSwitchValue;

void setup()   /****** SETUP: RUNS ONCE ******/
{
  pinMode(ModeSwitchPin,INPUT_PULLUP);
  RunMode = AutoMode;
//  RunMode = ManualMode;
  StartAutoModeOnce  = 1;
  StartManualModeOnce = 1;

}//--(end setup )---


void loop()   /****** LOOP: RUNS CONSTANTLY ******/
{
  ModeSwitchValue = digitalRead(ModeSwitchPin);
  
  if (ModeSwitchValue == ManualMode) 
  RunMode = ManualMode;
  else
  RunMode = AutoMode;
  
  if (RunMode == AutoMode)
  {
    if (StartAutoModeOnce == 1)
    {
      InitAuto();
      StartAutoModeOnce = 0;
    }

    //Change direction at the limits
    if (stepper1.distanceToGo() == 0)
    {
      stepper1.moveTo(-stepper1.currentPosition());
    }

    if (stepper2.distanceToGo() == 0)
    {
      stepper2.moveTo(-stepper2.currentPosition());
    }

  }// end Automode reversing
  
//------------------( MANUAL MODE )---------------------------------------  

  if (RunMode == ManualMode)
  {
    LeftPotValue  = 4 * analogRead(PotLeftMotorPin);    //Read the knob positions
    LeftMotorTarget = LeftPotValue;
    RightPotValue = 4 * analogRead(PotRightMotorPin);
    RightMotorTarget = RightPotValue;
    
    if (StartManualModeOnce == 1)
    {
      InitManual();
      StartManualModeOnce = 0;
    }    
    
    //Change direction at the limits
    if (stepper1.distanceToGo() == 0)
    {
      //      stepper1.moveTo(-stepper1.currentPosition());
      stepper1.moveTo(RightMotorTarget);
    }

    if (stepper2.distanceToGo() == 0)
    {
      stepper2.moveTo(LeftMotorTarget);
    }    
    
  }// END Manual Mode

  //----( ALWAYS run in Loop )-------
  stepper1.run();
  stepper2.run();

}//--(end main loop )---

/*-----( Declare User-written Functions )-----*/
void InitAuto()   /****** Automatic contra-rotation 1 rev ******/
{
  stepper1.setMaxSpeed(1000.0);
  stepper1.setAcceleration(50.0);
  stepper1.setSpeed(200);
  stepper1.moveTo(2048);  // 1 revolution

  stepper2.setMaxSpeed(1000.0);
  stepper2.setAcceleration(50.0);
  stepper2.setSpeed(200);
  stepper2.moveTo(-2048);  // 1 revolution
  
  StartManualModeOnce = 1;  

}//--(end InitAuto )---

void InitManual()   /****** Control By Knobs ******/
{
  stepper1.setMaxSpeed(1000.0);
  stepper1.setAcceleration(50.0);
  stepper1.setSpeed(200);
  stepper1.moveTo(20);  // 1 revolution

  stepper2.setMaxSpeed(1000.0);
  stepper2.setAcceleration(50.0);
  stepper2.setSpeed(200);
  stepper2.moveTo(-20);  // 1 revolution
  
  StartAutoModeOnce  = 1;  

}//--(end InitAuto )---

//*********( THE END )***********

TylerS:
I want to map a stepper to a pot. However, i'm having a little trouble figuring out where to start...

First thing that must happen when the Arduino program starts is to move the stepper back to the ZERO or HOME position. You will need some form of switch to detect when the motor gets to that point.

Once you identified the zero position you just need to map the 0-1023 range that the ADC gives for the potentiometer position to the 0 to 200 steps required from the motor. Dividing the ADC value by 5 will give a very close approximation.

...R
Stepper Motor Basics
Simple Stepper Code

also look up the AccelStepper library

I want to map a stepper to a pot. However, i'm having a little trouble figuring out where to start.

First, decide exactly what you want the stepper to do, when you move the pot.