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
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);
}