MOTOR IS NOT MOVING WHEN BUTTON IS PRESSED ARDUINO

Hi, I'm working with a push-on button switch and stepper motor. I am trying to make the motor to move forward and reverse once I press the button.

I have integrated the codes for the button and motor together, and they are working fine. The thing is, I have to constantly press the button for the motor to move.

 // constants won't change. They're used here to set pin numbers:
const int buttonPin = 4;     // the number of the pushbutton pin
const int ledPin =  7;      // the number of the LED pin

// variables will change:
boolean flag = true;
int buttonState = 0;         // variable for reading the pushbutton status
int distance = 0;   

void setup() {

  pinMode(buttonPin, INPUT);
  pinMode(ledPin, OUTPUT);
  pinMode(8, OUTPUT); //YELLOW
  pinMode(9, OUTPUT); //OREN
  
  digitalWrite(buttonPin, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);
}

void loop() {
  // read the state of the pushbutton value:
  buttonState = digitalRead(buttonPin);

  // check if the pushbutton is pressed. If it is, the buttonState is HIGH:
  if (digitalRead(buttonPin) == LOW) {

    digitalWrite(ledPin, HIGH);
    digitalWrite(8, LOW); //LOW=FORWARD DIRECTION
   digitalWrite(9, HIGH); //9 = MOTOR ON/OFF
   delayMicroseconds(100);
   digitalWrite(9, LOW);
   delayMicroseconds(100);
   distance++;

   if(distance > 21000){
    distance = 0;
    delay (3000);
    reverse();
    }
   
  } else {
    // turn LED off:
    digitalWrite(ledPin, LOW);
      digitalWrite(8, LOW); //LOW=FORWARD DIRECTION
   digitalWrite(9, LOW); //9 = MOTOR ON/OFF
   delayMicroseconds(100);
   digitalWrite(9, LOW);
   delayMicroseconds(100);
  }
}

void reverse(){

  digitalWrite(8,HIGH);

  digitalWrite(9,HIGH);
  delayMicroseconds(100);
  digitalWrite(9,LOW);
  delayMicroseconds(100);
  distance++;

   if(distance > 21000){
    distance = 0;
    delay (3000);
   return;
   }

   reverse();
   
  }

I have the code that lights up an led once the button is pressed, and will only turn off when the button is pressed again.

// Using a push button switch for stay-on/stay-off push button . 
// beating a dead horse, again. Most of the real work is from other people. 


int switch1 = 4; // connect a push button switch between this pin and ground
int ledpin = 7; // internal led, external LED, relay, trigger for other function, some other device, whatever.
boolean flag = true;

void setup()
{
  pinMode(ledpin,OUTPUT); // this pin controlled by flipflop() function
  pinMode (switch1,INPUT_PULLUP); // keeps pin HIGH via internal pullup resistor unless brought LOW with switch
  Serial.begin(9600); // just for debugging, not needed.
}

void loop()
{ 
  if (digitalRead(switch1)==LOW){ // check the state of switch1 every time we run through the main loop  
  delay(5); // I don't REALLY know why this delay helps, but it does. 
  flipflop(); // hops out of main loop and runs the flipflop function
  }// end of check for button press.

  // other sketch code here

} // end of main loop.

void flipflop(){  //funtion flipflop 
  flag = !flag;  // since we are here, the switch was pressed So FLIP the boolian "flag" state (we don't even care if switch was released yet)
  Serial.print("flag =   " );   Serial.println(flag);   // not needed, but may help to see what's happening.

  if (flag == HIGH){  // Use the value of the flag var to change the state of the pin
    digitalWrite(ledpin,HIGH ); // if the flag var is HIGH turn the pin on
  }
  if (flag == LOW) {
    digitalWrite(ledpin,LOW); // if the flag var is LOW turn the pin off 
  }
  while(digitalRead(switch1)==LOW); // for "slow" button release, keeps us in the function until button is UN-pressed
  // If you take out this "while" the function becomes a flipflop oscillator if the button is held down. 
  delay(50); // OPTIONAL - play with this value.  It is probably short enough to not cause problems. deals with very quick switch press.
}

I have combined the 'integrated' code with the 'turn on led' together. The problem is, the motor is not even moving when button is pressed. But, the button is still working because the led lights up when the button is pressed and turns off when button is pressed again.

const int buttonPin = 4;  // the number of the pushbutton pin
const int ledPin =  7;    // the number of the LED pin

int buttonState = 0; // variable for reading the pushbutton status
int distance = 0;   

boolean flag = true;

void setup() {

  pinMode(buttonPin, INPUT_PULLUP);
  pinMode(ledPin, OUTPUT);
  pinMode(8, OUTPUT); //YELLOW
  pinMode(9, OUTPUT); //OREN
  
  digitalWrite(buttonPin, HIGH);
  digitalWrite(8, HIGH);
  digitalWrite(9, HIGH);

  Serial.begin(9600); // just for debugging, not needed.
  
}



void balik(){

  digitalWrite(8,HIGH);
  digitalWrite(9,HIGH);
  delayMicroseconds(100);
  digitalWrite(9,LOW);
  delayMicroseconds(100);
  distance++;

  if(distance > 21000){
    distance = 0;
    delay (3000);
    return;
   }

   balik();
   
  }

void flipflop(){  //funtion flipflop 
 
  flag = !flag;  // since we are here, the switch was pressed So FLIP the boolian "flag" state (we don't even care if switch was released yet)
  Serial.print("flag =   " );   
  Serial.println(flag);   // not needed, but may help to see what's happening.

  if (flag == HIGH){  // Use the value of the flag var to change the state of the pin
   Serial.print("  THE BIGGER THE BETTER " );   
   digitalWrite(8, LOW);
     Serial.print("  THE BIGGER THE BETTER " );   
   digitalWrite(9, HIGH);
   delayMicroseconds(100);
   digitalWrite(9, LOW);
   delayMicroseconds(100);
   distance++;

   if(distance > 21000){
    distance = 0;
    delay (3000);
    balik();
    }
    Serial.print("CILLIAN MURPHY <3 " );   
    digitalWrite(ledPin,HIGH ); // if the flag var is HIGH turn the pin on
  }
  if (flag == LOW) {
   
    digitalWrite(ledPin,LOW); // if the flag var is LOW turn the pin off 
    digitalWrite(ledPin, LOW);
    digitalWrite(8, LOW); //LOW=FORWARD DIRECTION
    digitalWrite(9, LOW); //9 = MOTOR ON/OFF
    delayMicroseconds(100);
    digitalWrite(9, LOW);
    delayMicroseconds(100);
    
  }
  while(digitalRead(buttonPin)==LOW); // for "slow" button release, keeps us in the function until button is UN-pressed
  // If you take out this "while" the function becomes a flipflop oscillator if the button is held down. 
  delay(50); // OPTIONAL - play with this value.  It is probably short enough to not cause problems. deals with very quick switch press.
}

void loop() {

  buttonState = digitalRead(buttonPin);

  if (digitalRead(buttonPin)==LOW){ // check the state of switch1 every time we run through the main loop  
  delay(5); // I don't REALLY know why this delay helps, but it does. 
  flipflop(); // hops out of main loop and runs the flipflop function

}
}

Your help is very much appreciated