[Arduino noob] a simple code but I just don't know how to do

#include "SparkFun_Qwiic_Step.h" //Click here to get the library: http://librarymanager/All#Qwiic_Step by SparkFun
QwiicStep motor;
int run;
int buttonPin;

void setup()
{
  run = 0; //starts stopped
   buttonPin = 2; //whatever pin your button is plugged into

   pinMode(buttonPin, INPUT_PULLUP);
  Serial.begin(115200);
  Serial.println("Qwiic step examples");
  Wire.begin();

  //Check if Qwiic Step is correctly connected to I2C
  if (motor.begin() == false)
  {
    Serial.println("Device did not acknowledge! Freezing.");
    while (1)
      ;
  }
  Serial.println("Motor acknowledged.");
}

void loop()
{
  //code you always run here; you can leave this section blank if you want the entire program to stop and start, or add code here if you want it to always run

  //check button press here and if it is pressed then toggle run variable between 0 and 255; REQUIRED!
  if(digitalRead(buttonPin) == LOW) //funcitons based off of button pulling input pin LOW
  {
     if(run == 0)
     {
         run = 255;
     }
     else
     {
         run = 0;
     }
  }
  if(run > 0)
  {
     //code you only run if button was pressed, stops running when button pressed again, so forth...
    motor.move(700); //Turn one exact rotation of a 200 step stepper motor

  //Motor will be moving...
  }
}

I copy the example code from Arduino libraries and from other users.

Press the bottom then the stepper motor will run for a certain rotation. (here is 700)
then stop, then if i press again it will rotate another 700, repeat the same process.
that's it. but the code above happens to keep running forever when i press the bottom.

Have a look at the digital input examples in the IDE and get that working to say flash the internal LED on pin 13.
Then have a look at the stepper examples .

Getting other peoples code often can be frustrating , better to write your own

hammy:
Have a look at the digital input examples in the IDE and get that working to say flash the internal LED on pin 13.
Then have a look at the stepper examples .

Getting other peoples code often can be frustrating , better to write your own

thanks for your help. I'll look it up

These links may help.

Stepper Motor Basics
Simple Stepper Code

When looking for help about stepper motors it is a good idea to provide a link to the datasheet for the stepper motor as there are hundreds of different models. Also tell us what stepper motor driver you are using.

…R