Q's about using a button with a Stepper Motor

Hi everyone! I'm new to the Arduino community and this is my first project. I have been playing with the tutorials and understand how the button is used to light an LED. My problem is getting a button to turn a stepper motor. I would like to press a button to move the stepper motor. Then when the button is no longer pressed, the motor will revert back to it's original position. I am just a bit confused how to write the code for this. Forgive me for my newb-ish-ness :slight_smile:

I've been using this sample code so far to turn the stepper, but I can't seem to figure out how to add the button.

  #include <Stepper.h>           // include stepper library

    #define STEPS 200              // the number of steps per revolution

    // create an instance of the stepper class, specifying
    // the number of steps of the motor and the pins 
    Stepper stepper(STEPS, 8, 9, 10, 11);

    void setup()
    {
      stepper.setSpeed(60);       // set the speed of the motor in RPMs
    }

    void loop()
    {
      stepper.step(90);
      delay(500);
  
      stepper.step(-90);
      delay(500);
    }

http://www.arduino.cc/playground/Code/Buttons

Have a section of code that only runs when the button is pressed (if statement)

Then in that if - have a while statement loop that keeps on going as long as the button is pressed. In it you increment a counter, do a step and do the delay.

Then have a while statement loop that keeps going as long as the same counter is not equal to zero. In it you decrement the counter, do the step backwards and do the same delay.

This is then the end of your original if statement.

awesome info. thx for pointing me into the right direction guys