Use a push button to control stepper motor

I want to use push button 2 to make stepper motor on-off
and push button 1 to make it turn clockwise and counterclockwise

from my code, it's working but it's not working all the time that i push switch

const int SW1=51;const int SW2=53;
const int ENCODER1=38;const int ENCODER2=39;
const int STPMOTOR1=4;const int STPMOTOR2=5;
const int STPMOTOR3=6;const int STPMOTOR4=7;
const int Reset= 90;
void setup() {
  pinMode(SW1,INPUT);pinMode(SW2,INPUT);
  pinMode(STPMOTOR1,OUTPUT);pinMode(STPMOTOR2,OUTPUT);
  pinMode(STPMOTOR3,OUTPUT);pinMode(STPMOTOR4,OUTPUT);

}

int c=0;
int i=0;
int count=0; 
void loop() {
 
 if(digitalRead(SW2)==HIGH) { 
  do{
    if(digitalRead(SW1));{
   do{
    count++;
 
   if (count==5)count=1;
   if (count==1){digitalWrite(STPMOTOR1,HIGH);digitalWrite(STPMOTOR2,HIGH);digitalWrite(STPMOTOR3,LOW);digitalWrite(STPMOTOR4,LOW);}
   if (count==2){digitalWrite(STPMOTOR1,LOW);digitalWrite(STPMOTOR2,HIGH);digitalWrite(STPMOTOR3,HIGH);digitalWrite(STPMOTOR4,LOW);}
   if (count==3){digitalWrite(STPMOTOR1,LOW);digitalWrite(STPMOTOR2,LOW);digitalWrite(STPMOTOR3,HIGH);digitalWrite(STPMOTOR4,HIGH);}
   if (count==4){digitalWrite(STPMOTOR1,HIGH);digitalWrite(STPMOTOR2,LOW);digitalWrite(STPMOTOR3,LOW);digitalWrite(STPMOTOR4,HIGH);}
    delay(20);
    
   }while(digitalRead(SW1));}
   
    if(digitalRead(SW1));{ 
   do{
      count++;
 
   if (count==5)count=1;
   if (count==1){digitalWrite(STPMOTOR1,HIGH);digitalWrite(STPMOTOR2,HIGH);digitalWrite(STPMOTOR3,LOW);digitalWrite(STPMOTOR4,LOW);}
   if (count==2){digitalWrite(STPMOTOR1,HIGH);digitalWrite(STPMOTOR2,LOW);digitalWrite(STPMOTOR3,LOW);digitalWrite(STPMOTOR4,HIGH);}
   if (count==3){digitalWrite(STPMOTOR1,LOW);digitalWrite(STPMOTOR2,LOW);digitalWrite(STPMOTOR3,HIGH);digitalWrite(STPMOTOR4,HIGH);}
   if (count==4){digitalWrite(STPMOTOR1,LOW);digitalWrite(STPMOTOR2,HIGH);digitalWrite(STPMOTOR3,HIGH);digitalWrite(STPMOTOR4,LOW);}
  delay(20);
   
   }while(digitalRead(SW1));
  }
  
  if(digitalRead(SW2));
  }while(c%2==0);}
  digitalWrite(STPMOTOR1,LOW);digitalWrite(STPMOTOR2,LOW);digitalWrite(STPMOTOR3,LOW);digitalWrite(STPMOTOR4,LOW);delay(20);

 }
if(digitalRead(SW1))[color=red][b];[/b][/color]{
...
if(digitalRead(SW1))[color=red][b];[/b][/color]{ 
...
if(digitalRead(SW2))[color=red][b];[/b][/color]

Oooops

Suggest as well you put each motor sequence in different functions that will make it easier to read and use else statement

if (count==1) step1();
else
if (count==2) step2();
else
...

Pressing ctrl-T (or cmd-T on a Mac) will ident your code in the text editor, will make things easier to read

Also would be good to understand how you wired your buttons - (bouncing should be taken care off because you have delays builtin)