Oké, i am a step further. The stepper is reaching its position, takes a picture and goes to its next position and so on.
#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);
stepper.run();
if (stepper.distanceToGo() == 0)
{
delay(1000);
Serial.println("number of shots");
// digitalWrite(SHUTTER_PIN, LOW);
// delay(2000); // take shot
// digitalWrite(SHUTTER_PIN, HIGH);
stepper.setCurrentPosition(0);
}
}
//while(true) {} // execution does not proceed past this point
}
The next step is that it stops after 4 times.
When i remove the "//" before the rules: "for (int shot=0 ; shot < TotalShots ; shot++)" and "while(true) {} // execution does not proceed past this point"
it stops without moving the motor. I assume that it has to do with the same problem as before, that the motor has no time to reach it position. Is it not possible to complete the code after "for (int shot=0 ; shot < TotalShots ; shot++){}" before counting another shot?