stappenmotor met big easy shield en accelstepper

Ik ben er voorlopig weer uit.

Deze code doet wat ik wil dat het doet:

#define SHUTTER_PIN 7
#include <AccelStepper.h>
int TotalShots = 4;
long pos = 85924 / TotalShots; // 85924 is the total amound of steps te complete a rotation
AccelStepper stepper(1, 9, 8); // Define a stepper and the pins it will use

void setup() {                

  stepper.setMaxSpeed(4000);
  stepper.setAcceleration(4000);
  pinMode(SHUTTER_PIN, OUTPUT);
  Serial.begin(9600);
  Serial.println("start of the program");

}

void loop()  
{ 

for (int shot=0 ; shot < TotalShots ; shot++)

    { 
       stepper.moveTo(pos);   
      
         while (stepper.distanceToGo() != 0) 
             {
               stepper.run();
             }
             
         delay(2000);  
         Serial.println("number of shots"); 
         digitalWrite(SHUTTER_PIN, LOW);
         delay(2000);  // take shot
         digitalWrite(SHUTTER_PIN, HIGH);
         delay(2000);
         stepper.setCurrentPosition(0);
          
      
  }
while(true) {} // execution does not proceed past this point
}