Help in Stepper motor control with push button

Hi!
I'm quiet new this programming.
I'm trying to rotate my stepper motor using a push button for a certain angle. The push button is deteced only st the beginning. the loop is not continue.
I need some urgent help pleeeeaseeeeeee...

Thank u in advance!

below is the code I'm using

#include <Stepper.h>

const int button=2;
const int stepsPerRevolution = 200;
int buttonState = 0;
Stepper myStepper(stepsPerRevolution,13, 12, 11, 10);
boolean section = false;

void setup() {
// set the speed at 60 rpm:
myStepper.setSpeed(60);
// initialize the serial port:
Serial.begin(9600);
pinMode(button, OUTPUT);
}

void loop(){
buttonState = digitalRead(button);
if (buttonState==HIGH){
if(section==LOW){
myStepper.step(100); // turningthe motor to 25 steps to get 45 degree rotaion
section=true;

}
}
}

The problem is your section variable:

if(section==LOW){
    myStepper.step(100); // turningthe motor to 25 steps to get 45 degree rotaion
   section=true;

  }

Ignoring the fact that you're mixing up boolean values and LOW, the first time the button is pressed, section is false which happens to be zero, as is LOW, so the stepper steps and section is set to true (1). Next time the button is pressed, section isn't LOW any more and never will be again as you never change it, so the stepping portion isn't executed.

What is the section variable supposed to do?

Thank you so much for your reply and help..
True.. I did not specify what the variable should do.. I added two more lines and it works.. :slight_smile: