easy one(?) stepper motor

Hi all
Im trying to control a stepper motor with buttons.
Basicly what im trying to do here is when a button is pressed rotate to one diraction and then to another, when another button is pressed stop the motor.
This is my code:

void setup()
{

pinMode(2, INPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
pinMode(12, INPUT);
}

void loop()
{
bool push=digitalRead(2);
bool sw=digitalRead(12);

if (sw==HIGH)
{
int i=0;

for(i=0;i<512;i++)
{
if (push==1)
break;
clockwiserotate();
}

delay(1000);

for(i=0;i<512;i++)
{
if (push==1)
break;
counterclockwiserotate();
}
delay(1000);
}

The thing is, it doesnt stop when i press the button and it also shows me when im pressing the button that the voltage is 0

Thanks for the help!

Incomplete code, mismatches parentheses...

You currently read whether the button is pressed at the start of the loop. This will not change mid way through your loops, the only time it can change is after a DigitalRead. Hope this helps.

Thank

tammytam:
You currently read whether the button is pressed at the start of the loop. This will not change mid way through your loops, the only time it can change is after a DigitalRead. Hope this helps.

Thank you, it works now!

if (sw==HIGH)
 {
   int i=0;
 
  for(i=0;i<512;i++)
  {
   if (push==1)

Why are you not consistent? Use HIGH or LOW for all comparisons involving data read from pins.