int button1 = 8; 
int button2 = 11;
int motor1 = 10;
int motor2 = 13;
int state=false, dir=false;

void setup() {
  pinMode(motor1, OUTPUT);  
  pinMode(motor2, OUTPUT);      
  pinMode(button1, INPUT);  
  pinMode(button2, INPUT);     
}

void loop(){
  // run-stop
  if (digitalRead(button1) == HIGH) { 
    state=!state;
    while (digitalRead(button1) == HIGH) {
      delay(20);  
    }
  }
  // forward-reverse
  if (digitalRead(button2) == HIGH) { 
    dir=!dir;
    while (digitalRead(button2) == HIGH) {
      delay(20);  
    }
  }
  // execute commands
  if (state==true){  
    digitalWrite(motor2, dir); 
    digitalWrite(motor1, !dir); 
  }
  else{
    digitalWrite(motor2, LOW); 
    digitalWrite(motor1, LOW); 
  } 
}
