Help needed with my vending machine!

Hello!

For this project i am building a vending machine, i already have the dispensing figured out, but i am struggling with the vending part.

As i have thought it, I have a transistor cutting the power of my +5v to the rest of the circuit, that is what i named "dcPin" (located on Pin11). My plan is that every time the coin slides and makes the contact it will send a signal to the pin 12 (coinPin) that will activate the pin 11 and also the rest of the circuit. My problem is that the circuit is only activated for the period of time when the coin is making contact. I would like this dcPin to stay on, powering the circuit until one of the switches to dispense are pressed.

On the VOID LOOP section i have the WHILE command that activates the dcPin when the coin falls and makes the contact, but the digitalwrite to turn it off if located on the IF commands that are not activated until the switches are pressed.

Could somebody tell me what is wrong with my code?

CODE:

int motor1Pin=3;
int sw1Pin=2;
int motor2Pin=5;
int sw2Pin=4;
int pump3Pin=6;
int sw3Pin=7;
int pump4Pin=9;
int sw4Pin=8;

int coinPin=12;
int dcPin=11;

void setup()
{
pinMode(motor1Pin, OUTPUT);
pinMode(sw1Pin, INPUT_PULLUP);
pinMode(motor2Pin, OUTPUT);
pinMode(sw2Pin, INPUT_PULLUP);
pinMode(pump3Pin, OUTPUT);
pinMode(sw3Pin, INPUT_PULLUP);
pinMode(pump4Pin, OUTPUT);
pinMode(sw4Pin, INPUT_PULLUP);

pinMode(coinPin, INPUT_PULLUP);
pinMode(dcPin, OUTPUT);
}

void loop()
{
while (digitalRead(coinPin) == LOW)
digitalWrite(dcPin, HIGH);

if (digitalRead(sw1Pin) == LOW)
digitalWrite(motor1Pin, HIGH);
delay(1000);
digitalWrite(motor1Pin, LOW);
digitalWrite(dcPin, LOW);

if (digitalRead(sw2Pin) == LOW)
digitalWrite(motor2Pin, HIGH);
delay(2000);
digitalWrite(motor2Pin, LOW);
digitalWrite(dcPin, LOW);

if (digitalRead(sw3Pin) == LOW)
digitalWrite(pump3Pin, HIGH);
delay(3000);
digitalWrite(pump3Pin, LOW);
digitalWrite(dcPin, LOW);

if (digitalRead(sw4Pin) == LOW)
digitalWrite(pump4Pin, HIGH);
delay(4000);
digitalWrite(pump4Pin, LOW);
digitalWrite(dcPin, LOW);
}

Thank you very much!

You have this

if (digitalRead(sw1Pin) == LOW)
digitalWrite(motor1Pin, HIGH);
delay(1000);
digitalWrite(motor1Pin, LOW);
digitalWrite(dcPin, LOW);

Did you want

if (digitalRead(sw1Pin) == LOW)
{
    digitalWrite(motor1Pin, HIGH);
    delay(1000);
    digitalWrite(motor1Pin, LOW);
    digitalWrite(dcPin, LOW); 
}