Creating Pause Button

Hello I am writing a program in which we are trying to create a pause button in which we are controlling 2 pumps. I was wondering what would be the best method to implement this. Currently we just have a series of checks for when the button is pressed and a variable that changes when it is pressed. I was wondering if there is a better way of doing this rather than using the checks as we used. This will prevent us from pausing while a motor is running and being able to restart from that same time unless we store the time elapsed and that seemed like it would add much more complexity to it. Any advice would be very helpful. Thanks.

Attach your sketch so we can see what you are doing. See #7 HERE

this is vague. Code. How does i work now.. What change is desired

Sorry forgot to attach the code:

int pausePin = 7;
volatile int crisis=0;
volatile int check=1;
volatile int pauseState=0;
//volatile boolean stopState=false;
//volatile boolean startState=false;
volatile boolean pauseCheck=false;

void setup() {
  
  //Setup Channel A
  pinMode(12, OUTPUT); //Initiates Motor Channel A pin
  pinMode(9, OUTPUT); //Initiates Brake Channel A pin
  
  pinMode(13, OUTPUT); //Initiates Motor Channel B pin
  pinMode(8, OUTPUT); //Initiates Brake Channel B pin
  
  pinMode(7, INPUT); //Initiates pause button pin
  Serial.begin(9600);
}

void loop(){
  
  long starttime=millis();
  long timeinteger=5000UL;
  if(check==1 && pauseCheck==false)
  {
    while(millis() < starttime + timeinteger)
    {
      digitalWrite(12, HIGH); //Make Direction of A forward
      digitalWrite(9, LOW);  // Turn off Brake for A
      analogWrite(3, 255);  //Turn on Channel A at speed 127
      check=2;
      pauseState=digitalRead(7);
      Serial.print(pauseState);
    }
  }  

  digitalWrite(9, HIGH); //Turns Brake for A on
  
  pauseState=digitalRead(7);
  Serial.print(pauseState);
  if (pauseState==HIGH)
  pauseCheck=true;
  
  long starttimeB = millis();
  long timeintegerB=5000UL;
  if(check==2 && pauseCheck==false)
  {
    while(millis() < starttimeB + timeintegerB)
    {
      digitalWrite(13, HIGH); //Make Direction of B forward
      digitalWrite(8, LOW);  // Turn off Brake for B
      analogWrite(11, 255);  //Turn on Channel B at speed 127
      check=1;
        pauseState=digitalRead(7);
        Serial.print(pauseState);
    }  
      digitalWrite(8, HIGH); //Turns Brake for B on  
      delay(5000);

  }
  
  pauseState=digitalRead(7);
  Serial.print(pauseState);
  if (pauseState==HIGH)
   pauseCheck=true;

}

You do not appear to be using interrupts, so, why are:

volatile int crisis=0;
volatile int check=1;
volatile int pauseState=0;
//volatile boolean stopState=false;
//volatile boolean startState=false;
volatile boolean pauseCheck=false;

volatile?

  pinMode(7, INPUT); //Initiates pause button pin

This, by itself, implies that the switch is wired with external pullup or pulldown resistors. How IS your switch wired? Why aren’t you using the far simpler wiring using the internal pullup resistors?

    while(millis() < starttime + timeinteger)
    {
      digitalWrite(12, HIGH); //Make Direction of A forward
      digitalWrite(9, LOW);  // Turn off Brake for A
      analogWrite(3, 255);  //Turn on Channel A at speed 127
      check=2;
      pauseState=digitalRead(7);
      Serial.print(pauseState);
    }

Don’t you want to break of of this loop if the pause switch (NOT BUTTON!) is pressed?

    while(millis() < starttimeB + timeintegerB)
    {
      digitalWrite(13, HIGH); //Make Direction of B forward
      digitalWrite(8, LOW);  // Turn off Brake for B
      analogWrite(11, 255);  //Turn on Channel B at speed 127
      check=1;
        pauseState=digitalRead(7);
        Serial.print(pauseState);
    }

Same here. Not much point in reading the state of the pin that the switch is attached to, and then doing nothing more than printing the value.