Position eines Schrittmotors speichern

Hab ich jetzt verstanden :slight_smile:

So müsste es jetzt aber funktionieren oder?

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

// Create the motor shield object with the default I2C address
Adafruit_MotorShield AFMS = Adafruit_MotorShield(); 
// Or, create it with a different I2C address (say for stacking)
// Adafruit_MotorShield AFMS = Adafruit_MotorShield(0x61); 

// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #2 (M3 and M4)
Adafruit_StepperMotor *bigMotor = AFMS.getStepper(200, 2);
// Connect a stepper motor with 200 steps per revolution (1.8 degree)
// to motor port #1 (M1 and M2)
Adafruit_StepperMotor *smallMotor = AFMS.getStepper(513,1);

const int minPoti = 0;
const int maxPoti = 1023;
int einAusPin = 2;
int potiPin = 0;
int i = 0;


void setup() {
  //Serial.begin(9600);           // set up Serial library at 9600 bps
  pinMode(einAusPin, INPUT);            // PIN 2 = INPUT (Haupttaster)
  
  //Serial.println("CASE ANNEALER!");

  AFMS.begin();  // create with the default frequency 1.6KHz
  //AFMS.begin(1000);  // OR with a different frequency, say 1KHz
  
  bigMotor->setSpeed(6);    // 6 rpm  
  smallMotor->setSpeed(60);  // 60 rpm   
}

void loop() {
  
  int einAusSchalter;
  int wertPoti;
  int sekunden;

  einAusSchalter = digitalRead(einAusPin);
  
  if (einAusSchalter == HIGH){

    if (i == 0){
      delay(4000);      // 4 Sekunden bis die Rotation beginnt
    }
    else{
      i++;  
      wertPoti = analogRead(potiPin);
      sekunden = map(wertPoti, minPoti, maxPoti, 0, 14);

      if(sekunden){
        bigMotor->step(20, FORWARD, SINGLE);    // Hauptmotor dreht bis zur nächsten Hülse 
        smallMotor->step(513*sekunden, FORWARD, SINGLE);  // Drehteller dreht sich
      }
      delay(1);   // Pause für Stabilität zwischen dem Einlesen 
    }
  }
  else{
    //Nichts
  }
}

Danke und LG