Camera Slider Movement Help

Hello, I am working on a camera slider project that is using a stepper motor to move a camera a set distance over different amounts of time. I found a some come that was using a stepper motor with a linear screw attached and I am wanting to use a stepper with a 2GT belt and two 20 teeth pulleys. This whole project is based around the Adafruit Feather ESP32, and OLED Screen, and an Adafruit Featherwing Stepper Driver. Attached is the existing code and I have looked through it and I can't seem to figure out how to get it to move the way I want it to. I know that with the two 20 teeth pulleys and the 2GT belt with a 2mm pitch and the 1.8 degree stepper motor I am getting .2mm per step. I am needing help badly! Thanks in advance.

/*
 * This is a sketch to control my camera slider for filming time lapses. It uses the Adafruit DC Motor + Stepper FeatherWing,
 * The OLED FeatherWing and the Feather ESP32 board. The sequence can run from 5 minutes to 8 hours and supports a span of any length.  
 * Get all of the other resources at https://github.com/556duckvader/CameraSlider.
 * 
 * Written by Dustin Norton, 2019
 */


#include <SPI.h>
#include <Wire.h>
#include <Adafruit_GFX.h>
#include <Adafruit_SSD1306.h>
#include <Adafruit_MotorShield.h>
#include "utility/Adafruit_MS_PWMServoDriver.h" 

spanLength = 22000;  // Change this to your span length (in millimeters) * 25
unsigned long oldTime = 0;
unsigned long currentTime;

Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
Adafruit_StepperMotor *myMotor = AFMS.getStepper(200, 2);

Adafruit_SSD1306 display = Adafruit_SSD1306(128, 32, &Wire);

  // OLED FeatherWing buttons map to different pins depending on board:
#if defined(ESP8266)
  #define BUTTON_A  0
  #define BUTTON_B 16
  #define BUTTON_C  2
#elif defined(ESP32)
  #define BUTTON_A 15
  #define BUTTON_B 32
  #define BUTTON_C 14
#elif defined(ARDUINO_STM32_FEATHER)
  #define BUTTON_A PA15
  #define BUTTON_B PC7
  #define BUTTON_C PC5
#elif defined(TEENSYDUINO)
  #define BUTTON_A  4
  #define BUTTON_B  3
  #define BUTTON_C  8
#elif defined(ARDUINO_FEATHER52832)
  #define BUTTON_A 31
  #define BUTTON_B 30
  #define BUTTON_C 27
#else // 32u4, M0, M4, nrf52840 and 328p
  #define BUTTON_A  9
  #define BUTTON_B  6
  #define BUTTON_C  5
#endif

void setup() {  
  Serial.begin(115200);
  
  delay(500);

  Serial.println("OLED FeatherWing test");
  // by default, we'll generate the high voltage from the 3.3v line internally! (neat!)
  display.begin(SSD1306_SWITCHCAPVCC, 0x3C);  // initialize with the I2C addr 0x3C (for the 128x32)
  // init done
  Serial.println("OLED begun");

  AFMS.begin();  // create with the default frequency 1.6KHz
  myMotor->setSpeed(20);  // 10 rpm   
  
  // Show image buffer on the display hardware.
  // Since the buffer is intialized with an Adafruit splashscreen
  // internally, this will display the splashscreen.
  display.display();
  delay(1000);

  // Clear the buffer.
  display.clearDisplay();
  display.display();
  
  Serial.println("IO test");

  pinMode(BUTTON_A, INPUT_PULLUP);
  pinMode(BUTTON_B, INPUT_PULLUP);
  pinMode(BUTTON_C, INPUT_PULLUP);
  pinMode(ENDSTOP, INPUT_PULLUP);
}

void loop() {

  //Display that we're starting the homing sequence
  display.setTextSize(1);
  display.setTextColor(SSD1306_WHITE);
  display.setCursor(0,0);
  display.print("Homing, please wait.");
  display.display(); // actually display all of the above

  // Homing sequence: we're running the motor until the endstop switch is hit.
  int homing = 1;
  while (homing) {
    myMotor->onestep(BACKWARD, DOUBLE);
    if (digitalRead(ENDSTOP) == 0) {
      delay(50);
      Serial.println("Endstop Hit");
      homing = 0;
    }
  }
  
  // once homed, back the motor off by 2mm
  for (int i = 0; i <= 50; i++) {
    myMotor->onestep(FORWARD, DOUBLE);
  }
  delay(250);
  display.clearDisplay();
  display.display();
  
  display.setTextColor(WHITE, BLACK);
  display.setCursor(0,0);
  display.print("Homing Complete!");
  display.display();
  delay(1500);
  
  // Get input from user for the sequence runtime
  int minutes = 5;
  int timeinput = 1;
  unsigned long timer;
  int progress;

  //Display for user input
  display.clearDisplay();
  display.display();
  delay(50);
  display.setCursor(0,0);
  display.println("Span Travel Time");
  display.setCursor(24,8);
  display.print("Minutes");
  display.display();
  
  while (timeinput) {
    //Drawing rectangles is faster than clearing the whole display
    display.setCursor(0,8);
    display.fillRect(0,8,24,8,BLACK);
    display.setTextColor(WHITE, BLACK);
    display.print(minutes);
    display.display();

    //Use the buttons as cursor keys to select the runtime
    if (! digitalRead(BUTTON_A)) {
      if (minutes >= 5 && minutes < 30) minutes += 5;
      else if (minutes >= 30 && minutes < 120) minutes += 15;
      else if (minutes >=120 && minutes < 480) minutes += 30;
    }
    if (! digitalRead(BUTTON_C)) {
      if (minutes > 5 && minutes <= 30) minutes -= 5;
      else if (minutes > 30 && minutes <= 120) minutes -=15;
      else if (minutes > 120 && minutes <= 480) minutes -= 30; 
    }
    
    // Hit the middle button to confirm your runtime
    if (! digitalRead(BUTTON_B)) timeinput = 0;
    delay(100);
  }
  display.clearDisplay();
  display.display();
  delay(100);

  //Clear display, then set it up to start the program

  display.fillRect(0,0,128,32,BLACK);
  display.display();
  delay(100);
  display.setCursor(0,8);
  display.println("Program Starting");
  display.display();
  delay(1500);
  display.fillRect(0,8,128,16,BLACK);
  display.display();

  //Determine the interval time between motor steps
  timer = minutes * 60000;
  float interval = (float)timer / (float)spanLength;
  oldTime = millis();
  int currentPos = 0;

  // Set up display for status while program is running
  display.setCursor(0,0);
  display.println("Program Running");
  display.drawRect(0,10,128,12, WHITE);
  display.setCursor(0,24);
  display.print("Minutes Left:");
  display.display();

  //Loop that runs the motor during the sequence
  while (currentPos < spanLength) {
    currentTime = millis();
    if ((currentTime - oldTime) >= interval) {
      //move the motor
      myMotor->onestep(FORWARD, DOUBLE);
      
      //update the position reference
      currentPos++;

      //update the clock
      oldTime = currentTime;
      timer -= interval;

      //update the progress bar
      progress = map(currentPos, 0, spanLength, 2, 126);
      display.fillRect(2, 12, progress, 8, WHITE);

      //update the onscreen timer
      display.fillRect(80,24,128,32, BLACK);
      display.setCursor(80,24);
      display.print((timer / 60000) +1);
      display.display();

    }

  }
  //we're done! Update display and reset everything.
  delay(2000);
  display.fillRect(0,0,128,32,BLACK);
  display.display();
  display.setCursor(0,0);
  display.println("Program Complete.");
  display.display();
  delay(5000);  
  display.fillRect(0,0,128,32,BLACK);
  display.display();

}

"I can't seem to figure out how to get it to move the way I want it to."

Does the stepper motor move at all? If not, then you may need to drop back and write some code that will verify the hardware/motor is working ok.

zoomkat:
"I can't seem to figure out how to get it to move the way I want it to."

Does the stepper motor move at all? If not, then you may need to drop back and write some code that will verify the hardware/motor is working ok.

Yes it moves just fine. The issue I guess I should have stated is that I have a piece of 2040 extrusion that I have a total travel distance of 880mm and I am wanting to select a specified amount of time and I want it to cover the total 880mm in that amount of time. So if I select 10 minutes using the buttons it will move 880mm over 10 minutes

If you haven't already, use the forum search function in the upper right of the screen and search for "camera slider", as it has been a somewhat popular project in times past. You might find some stepper motor code that has the bugs already worked out.