Help with steppermotor program

Hi guys,

I need some help with my program. It works fine as it is, but It needs more and I can’t pull it off so far.

So my steppermotor takes 10 steps if the inputsignal is high, works fine.

Now my problem: the steppermotor will have to do this 60times. So 60 times 10steps (1080 degrees). After the 60 times it needs to go back to It’s formal position ( DIR_PIN (HIGH) ).

How to do this? :confused: Code so far:

#define STEP_PIN 2 //STEP
#define DIR_PIN 3 //Direction
#define BUTTON 7 // input signal
#define LED 5 // LED



void setup()
{
  pinMode (LED, OUTPUT);
  pinMode (BUTTON, INPUT);
  pinMode(DIR_PIN, OUTPUT);
  pinMode(STEP_PIN, OUTPUT);
  digitalWrite(DIR_PIN, LOW);
  digitalWrite(STEP_PIN, LOW);
  digitalWrite (LED, LOW);

}

void loop()
{
  int buttonState = digitalRead(BUTTON);
  if (buttonState == HIGH)
  {
    for (int i = 0; i < 10; i++) {

      delay (20);
      digitalWrite(STEP_PIN, HIGH);
      delay(2);
      digitalWrite(STEP_PIN, LOW);
      delay(2);
      digitalWrite (LED, HIGH);

    }
  }
  else
  {
    digitalWrite (LED, LOW);
    digitalWrite (STEP_PIN, LOW);
  }

}

It sounds like you need a variable to keep count of the total number of steps so that you can do the same number in the other direction.

...R Stepper Motor Basics Simple Stepper Code