Steuerung eines Kamerasliders

Doc_Arduino:
Oder es läuft wieder auf einen Zustandsautomaten hinaus. Läuft auch permanent durch. Dafür liefert dir sicherlich agmue seine Bsp. und Link.

Das hatte ich schon mal gemacht, fand aber nicht so den Anklang (Stand 24.4.2016):

#include <AccelStepper.h>

#define TASTERpin  2
#define STEPpin  8
#define DIRpin   9
#define AusloeserPin 13
AccelStepper Xaxis(1, STEPpin, DIRpin);
const unsigned long ruhe = 1000, aufnahme = 100, pause = 500;
unsigned long aktMillis, fotoMillis;
long pos;
enum {WARTEN, BEWEGUNG, BERUHIGUNG, AUFNAHME, PAUSE};
const byte maxZ = 5;
byte zaehler, zustand = WARTEN;

void setup() {
  Serial.begin(9600);
  Serial.println("Anfang");
  pinMode(TASTERpin, INPUT_PULLUP);
  pinMode(AusloeserPin, OUTPUT);
  Xaxis.setMaxSpeed(500);
  Xaxis.setAcceleration(500);
}

void loop() {
  aktMillis = millis();
  switch (zustand) {
    case WARTEN:
      if (digitalRead(TASTERpin)) {
        pos = analogRead(A0);
        Serial.print("pos: ");
        Serial.println(pos);
        Xaxis.move(pos);
        zustand = BEWEGUNG;
      }
      break;
    case BEWEGUNG:
      if (Xaxis.distanceToGo() == 0) {
        fotoMillis = aktMillis;
        zustand = BERUHIGUNG;
      }
      break;
    case BERUHIGUNG:
      if (aktMillis - fotoMillis >= ruhe) {
        digitalWrite(AusloeserPin, HIGH);
        fotoMillis = aktMillis;
        zustand = AUFNAHME;
      }
      break;
    case AUFNAHME:
      if (aktMillis - fotoMillis >= aufnahme) {
        digitalWrite(AusloeserPin, LOW);
        fotoMillis = aktMillis;
        zustand = PAUSE;
      }
      break;
    case PAUSE:
      if (aktMillis - fotoMillis >= pause) {
        zaehler++;
        zaehler = zaehler % maxZ;
        if (!zaehler) {
          Serial.println("Fertig, warten auf neuen Zyklus.");
          zustand = WARTEN;
        } else {
          Xaxis.move(pos);
          zustand = BEWEGUNG;
        }
      }
      break;
  }
  Xaxis.run();
}