Delays  makeing and destroyin my program help!

#include <LCD4Bit.h>

LCD4Bit lcd = LCD4Bit(2);

int analogPin = 3; // potentiometer wiper (middle terminal) connected to analog pin 3
// outside leads to ground and +5V
int val = 0; // variable to store the value read

int outPin = 5;
int outPin1 = 4;
int outPin2 = 3;
int outPin3 = 4;
int outPin4 = 5;

void setup()
{
pinMode(outPin, OUTPUT);
pinMode(outPin1, OUTPUT);
pinMode(outPin2, OUTPUT);
pinMode(outPin3, OUTPUT);
pinMode(outPin4, OUTPUT);

//low=off=up

pinMode(13, OUTPUT); //we’ll use the debug LED to output a heartbeat

lcd.init();
//optionally, now set up our application-specific display settings, overriding whatever the lcd did in lcd.init()
//lcd.commandWrite(0x0F);//cursor on, display on, blink on. (nasty!)

Serial.begin(9600); // setup serial
}

void loop()
{
digitalWrite(outPin, HIGH); //sw 5
digitalWrite(outPin1, LOW); //sw 4
digitalWrite(outPin2, HIGH); //sw 3
digitalWrite(outPin3, HIGH); //sw 2
digitalWrite(outPin4, HIGH); //sw 1

lcd.cursorTo(1, 0); //line=2, x=0.
lcd.printIn(“PHASE TO PHASE”);
lcd.cursorTo(2, 0); //line=2, x=0.
lcd.printIn(“1-2 WYE”);

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^

do
{
delay(2000);
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
} while (val<50);

do
{

delay(3000);
val = analogRead(analogPin); // read the input pin
Serial.println(val); // debug value
} while (val<50);

char str[10];
sprintf(str, " A/D %d", val);
lcd.printIn(str);

delay(5000);
lcd.clear();

//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

if (val>370 && val<400)
{
lcd.printIn(“208V CORRECT”);
}
else
{
lcd.printIn(“INCORRECT”);
}

delay(5000);
lcd.clear();

}

That is my code but the delay is turning on my last relay on switch one it keeps flippin it.
does someone know a code to section off or specify what is supposed to be delayed or know some other code i could use to pause the screen or something. It keeps flippin the last relay.

but the delay is turning on my last relay on switch one it keeps flippin it

Can you explain that sentence please?

While you are explaining things, can you explain this:

int outPin = 5;
int outPin1 = 4;
int outPin2 = 3;
int outPin3 = 4;
int outPin4 = 5;

It appears as though you have multiple names for the same physical pin, and that you are turning the pin on or off using multiple names.

Hmm you got me scratching my head.
Not because I'm confused about why the arduino is acting weird, but because I can't understand what you're trying to say.

Typically, I would declare variables that related to pin numbers. If I have an LED attached to pin 11, I might create a variable:

int ledPin = 11;

If I had 3 LEDs, attached to pins 11, 10, and 9, I might do this:

int greenLED = 11;
int yellowLED = 10;
int redLED = 9;

What I would not do, though, is:

int greenLED = 11;
int yellowLED = 10;
int redLED = 11;

If I did that, and I wrote:

// Turn the red LED on
digitalWrite(redLED, HIGH);
// Turn the green LED off
digitalWrite(greenLED, LOW);

and I then asked you why I couldn't have the red LED and the green LED on at the same time, would you be able to tell me?

In OP's code, there are two variables that refer to pin 5 and 2 that refer to pin 4. There are 5 statements the define pins as output pins, but there are only 3 pins referenced.

Then there is this:

digitalWrite(outPin, HIGH);    //sw 5
digitalWrite(outPin1, LOW); //sw 4
digitalWrite(outPin2, HIGH);  //sw 3
digitalWrite(outPin3, HIGH);  //sw 2
digitalWrite(outPin4, HIGH);  //sw 1

At the end of this, what is the state of pin 4?