How to execute my script with a button (stepper motor)

I built a turntable for VR object photography with a stepper motor and my code turns the motor about a half turn. I need to operate it (run the script) with a button press instead of running the script from the computer. I've been searching the forums and I'm still not sure how to do that. Can someone help? I'm new to this with no background in programming. Thanks!!

Here's my code:

/*
Stepper Motor Demonstration 1
Stepper-Demo1.ino
Demonstrates 28BYJ-48 Unipolar Stepper with ULN2003 Driver
Uses Arduino Stepper Library

DroneBot Workshop 2018

*/

//Include the Arduino Stepper Library
#include <Stepper.h>

// Define Constants

// Number of steps per internal motor revolution
const float STEPS_PER_REV = 32;

// Amount of Gear Reduction
const float GEAR_RED = 64;

// Number of steps per geared output rotation
const float STEPS_PER_OUT_REV = STEPS_PER_REV * GEAR_RED;

// Define Variables

// Number of Steps Required
int StepsRequired;

// Create Instance of Stepper Class
// Specify Pins used for motor coils
// The pins used are 8,9,10,11
// Connected to ULN2003 Motor Driver In1, In2, In3, In4
// Pins entered in sequence 1-3-2-4 for proper step sequencing

Stepper steppermotor(STEPS_PER_REV, 8, 10, 9, 11);

void setup()
{
// Nothing (Stepper Library sets pins as outputs)
}

void loop()
{
// Rotate CW 1/2 turn quickly
StepsRequired = STEPS_PER_OUT_REV / 2;
steppermotor.setSpeed(700);
steppermotor.step(StepsRequired);
delay(2000);

}

Please modify you post and put in code tags as suggested by the forum guide in the sticky post.

dmpreisler:
I've been searching the forums and I'm still not sure how to do that. Can someone help? I'm new to this with no background in programming. Thanks!!

Did you not check the forums?

Button
StateChangeDetection

Robin2's simple stepper program example.

steppermotor.setSpeed(700); :o

About 16 ~ 17 RPM is all I've gotten out of a 28BYJ-48 without acceleration and without missing steps, and that's with FULL rated voltage and no load. I HAVE gotten up to 25 RPM with the AccelStepper library.
Anyway, connect one of your button wires to Arduino GND and the other to a digital input pin, (I used pin 4 here) and try this simple sketch.

#include <Stepper.h>

// Define Constants

// Number of steps per internal motor revolution
const int STEPS_PER_REV = 2048;
const byte buttonPin = 4;
bool pressed = true, lastPressed = true;


// Number of Steps Required
int StepsRequired;

// Create Instance of Stepper Class
// Specify Pins used for motor coils
// The pins used are 8,9,10,11
// Connected to ULN2003 Motor Driver In1, In2, In3, In4
// Pins entered in sequence 1-3-2-4 for proper step sequencing

Stepper steppermotor(STEPS_PER_REV, 8, 10, 9, 11);

void setup()
{
  pinMode(4,INPUT_PULLUP);
// Nothing  (Stepper Library sets pins as outputs)
}

void loop()
{
// Rotate CW 1/2 turn quickly
  StepsRequired  = STEPS_PER_REV / 2;   
  steppermotor.setSpeed(12);
  pressed = digitalRead(buttonPin);
  if(pressed != lastPressed) // if pin state changed
  {
    delay(50); // simple switch debounce
    lastPressed = pressed;
    if(!pressed) // pin changed from HIGH to LOW
    {
      steppermotor.step(StepsRequired); // DO IT!
    }   
  }
  //delay(2000);
}