Help with Button

I am trying to start a loop with the press of a button, I am using the attached code. As soon as I run the rest of the loop begins, regardless of the button press. This is not the case with simple test code below, it works as I had hoped. I can't quite see what I am missing!

// Define
int led = 13;
int led2 = 12;
int led3 = 11;
int motorPin = 2;
int motorPin2 = 3;
int motorPin3 = 4;
int buttonPin = 5;     // the number of the pushbutton pin

// the setup routine runs once when you press reset:
void setup() {
 pinMode(led, OUTPUT);
 pinMode(led2, OUTPUT);
 pinMode(led3, OUTPUT);
 pinMode(motorPin, OUTPUT);  // setup Agitation Pump
 pinMode(motorPin2, OUTPUT);  // setup Dev IN Pump
 pinMode(motorPin3, OUTPUT);  // setup Dev OUT Pump
 pinMode(buttonPin, INPUT); // setup Button
}


void loop() {
 
 while (digitalRead(buttonPin) == HIGH) {

 delay(3000);
   
 //DEVELOPER
 digitalWrite(led, HIGH);   // Dev LED on
 
 analogWrite(motorPin2, 200);  // Dev FILL pump on for 3 seconds
 delay(3000);
 analogWrite(motorPin2, 0);    // Dev FILL pump off
 
 delay(3000); //Start Process for 3 seconds
 
 analogWrite(motorPin, 200);  // Agitate for 3 seconds
 delay(3000);
 analogWrite(motorPin, 0);    // Agitate stop
 
 delay(3000); //Continue process for 3 seconds
 
 analogWrite(motorPin3, 200);  // Dev DRAIN pump for 3 seconds
 delay(3000);
 analogWrite(motorPin3, 0);    // Dev DRAIN pump stop
 
 digitalWrite(led, LOW);  //Dev LED off
 
 }
 
}

My proof of concept seems to be working with this code:

const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin


void setup() {
 // initialize the LED pin as an output:
 pinMode(ledPin, OUTPUT);
 // initialize the pushbutton pin as an input:
 pinMode(buttonPin, INPUT);
}

void loop() {

 while (digitalRead(buttonPin) == HIGH) {
 

  delay (3000);
   digitalWrite(ledPin, HIGH);  


   }
 
}

Working:

Not Working:

I have a really hard time understanding the wiring of a switch with external resistors. I have to study the pictures forever.

Using the internal pullup resistor, with one leg connected to the digital pin and one leg connected to ground, the schematic is intuitive.

Why do you want to add unnecessary hardware?

I can't really figure out why you rotated the board between the two examples, and why the switch in the non-working picture doesn't have all 4 pins in holes in the bread-board.

I can't figure out why you clipped the wires off in the second picture. Didn't you think we'd want to see the whole picture?

Here is the entire circuit, I though I was using the transistor correctly for my motors.

Here is the entire circuit

What's that green wire on the top, left for?

It is going to the ground at the top of the breadboard.

jeffreyl:
It is going to the ground at the top of the breadboard.

But you cut the picture off again?

I am currently just testing in circuits.io, would that sim reproduce the voltage sag/reset?