problem with programming my sequence

Dear readers,
i have some trouble with programming a sequence on the arduino.

what it should do:
ignore switch5 and motor4 rotate until switch 4 is pressed, after this switch 4 locked into on state–>

motor 1,2,3 rotate until switch 3 is pressed–>

motor 1,2,3 keep rotating motor4 reverse rotation until switch 1 is pressed, switch 1 is locked into on state–>
motor 1,2,3 keep rotating and stop when switch 5 is pressed, switch 5 is locked into on state.
return to start

when the motors turn the switches 1,4,5 will release themselves
i’ve tried multiple methods but i cannot find the problem.

please help.
last atempt code:

#include <AFMotor.h>

AF_DCMotor motor1(1);
AF_DCMotor motor2(2);
AF_DCMotor motor3(3);
AF_DCMotor motor4(4);

int switchPin1 = 13; //pin13
int switchPin2 = 2; // pin02
int switchPin3 = 15; //a1
int switchPin4 = 16; //a2
int switchPin5 = 17; //a3
int val1;
int val2;
int val3;
int val4;
int val5;

void setup() {
Serial.begin(9600); // set up Serial library at 9600 bps
Serial.println(“Motor test!”);
pinMode(switchPin1, INPUT);
pinMode(switchPin2, INPUT);
pinMode(switchPin3, INPUT);
pinMode(switchPin4, INPUT);
pinMode(switchPin5, INPUT);

// turn on motor
motor1.setSpeed(1);
motor1.run(RELEASE);
motor2.setSpeed(1);
motor2.run(RELEASE);
motor3.setSpeed(1);
motor3.run(RELEASE);
motor4.setSpeed(1);
motor4.run(RELEASE);

}
void loop(){

val1 = digitalRead(switchPin1);
val2 = digitalRead(switchPin2);
val3 = digitalRead(switchPin3);
val4 = digitalRead(switchPin4);
val5 = digitalRead(switchPin5);

while(val1 == HIGH) {
motor4.run(BACKWARD);
motor4.setSpeed(220);

}
while(val4 == HIGH) {deuropen();}

while(val3 == HIGH) { deursluiten();}

while(val1 == HIGH) { door();}

while(val5 == HIGH) { einde();}

}
void deuropen(){

val1 = digitalRead(switchPin1);
val2 = digitalRead(switchPin2);
val3 = digitalRead(switchPin3);
val4 = digitalRead(switchPin4);
val5 = digitalRead(switchPin5);

motor4.run(RELEASE);
motor1.run(FORWARD);
motor1.setSpeed(80);
motor2.run(FORWARD);
motor2.setSpeed(80);
motor3.run(BACKWARD);
motor3.setSpeed(220);

}

void deursluiten(){
val1 = digitalRead(switchPin1);
val2 = digitalRead(switchPin2);
val3 = digitalRead(switchPin3);
val4 = digitalRead(switchPin4);
val5 = digitalRead(switchPin5);

motor4.run(BACKWARD);
motor4.setSpeed(220);
motor1.run(FORWARD);
motor1.setSpeed(80);
motor2.run(FORWARD);
motor2.setSpeed(80);
motor3.run(BACKWARD);
motor3.setSpeed(220);

}
void door(){
val1 = digitalRead(switchPin1);
val2 = digitalRead(switchPin2);
val3 = digitalRead(switchPin3);
val4 = digitalRead(switchPin4);
val5 = digitalRead(switchPin5);

motor4.run(RELEASE);
motor1.run(FORWARD);
motor1.setSpeed(80);
motor2.run(FORWARD);
motor2.setSpeed(80);
motor3.run(BACKWARD);
motor3.setSpeed(220);

}
void einde(){
motor3.run(RELEASE);
motor2.run(RELEASE);
motor1.run(RELEASE);

delay(1000);
}

Pretty hard to follow (or it's just too late and I should go to bed :-) but how do you get out of this loop ?

void loop(){

val1 = digitalRead(switchPin1); val2 = digitalRead(switchPin2); val3 = digitalRead(switchPin3); val4 = digitalRead(switchPin4); val5 = digitalRead(switchPin5);

while(val1 == HIGH) { // how do we get out of here ? motor4.run(BACKWARD); motor4.setSpeed(220);

}

HTH

i think we should ignore the while part, because it doesnt work and could possibly be replaced with somthing else