Stepper motor using millis

Hello! I am trying to controll a steppermotor. I have done some progress but need some advice.
What I am trying to do.

  1. The motor need to go down if pos is up and button is pressed, and up if it is down and the button is pressed, (this is done.)

  2. It should be possible to interupt the event, so while the motor is running from pos a to pos b it should stop and on next button press it should go back to pos a.

This is so far, when that is done I am planning to add double clicking and it going to pos between pos a and b. That is not relevant at this point.

So I am done with point 1 and moving on to point 2, any suggestions?

My code for point 1 is this.

#include <AccelStepper.h>

#define FULLSTEP 4
const int buttonPin = 7;  
int buttonState = 0;  

//  IN1-IN3-IN2-IN4
AccelStepper myStepper(FULLSTEP, 2, 4, 3, 5);

void setup() {

   pinMode(buttonPin, INPUT);

void loop() {
  buttonState = digitalRead(buttonPin);

void stepper1pos()
   if (buttonState == HIGH && (myStepper.currentPosition() == 0))

void stepper2pos()
  if (buttonState == HIGH && (myStepper.currentPosition() == 3000))

And cross posted here

Do not cross post. Reported.


Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you also take a few moments to Learn How To Use The Forum.

Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.

Put the line;

as the last thing in loop() and delete it from your functions.