Turning stepper motor on and off with button

I have very basic arduino knowledge so please excuse me if I make mistakes.

I am trying to program arduino with a button that does something quite simple.
If i press the button the stepper starts moving and if i press it again it stops moving.
I was also looking at another option (mode1 stepper moves slow, mode2 stepper moves fast, mode 3 off, back to mode 1)
I wanted to make this work with:

if (state == 3) { 
           state = 0;
                    }

 if (button1 == HIGH){
           state++;
                             }
if (state == 0) {do nothing;}
if (state == 1) {do something1;}
if (state == 2) {do something2;}
if (state == 3) {do something3;}

but the problem is I can't figure out what to type for stepper to move and stop into the if states

I have already looked at the following forums but became none the wiser into how to apply it for my code.
https://docs.arduino.cc/learn/electronics/stepper-motors

.

I would really appreaciate if someone could help me further.

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.