ATS GENERATOR

excuse me I learned the arduino program and I want to make a project at. but the problem is in the delay and while so I have to wait for the delay program to stop, and the difficulty to make it work properly ... please help me how the project is correct ... my native language is Indonesia, so sorry if my english is not good. thank you

void loop()
{
delay(100);
if (digitalRead(Psen) == LOW) //listrik on
{
lcd.clear();
lcd.setCursor (0,0);
lcd.print(" ----PLN ON----");

if(digitalRead(Gsen) == LOW){

delay(60000);

//if (millis()- durasi5 > jeda5) {
//durasi5 = millis();
if (digitalRead(Psen) == HIGH) {
digitalWrite(gon, LOW);
digitalWrite(pon, HIGH) ;
digitalWrite(gstb, HIGH);
}
else
{
lcd.clear();
lcd.setCursor (0,0);
lcd.print(" TEGANGAN PLN");
digitalWrite(gstr, HIGH) ;
while (timeDelay3 > 0) { // matikan genset
if (millis()- durasigstr > jedagstr) {
durasigstr = millis();
digitalWrite(gon, HIGH);
digitalWrite(pon, LOW) ;
if (statusgstr == HIGH) {
statusgstr = LOW; }

else {
statusgstr = HIGH; }
digitalWrite(gstb,statusgstr);
timeDelay3 = timeDelay3-1000; }}

}

}

else {
lcd.clear();
lcd.setCursor (0,0);
lcd.print(" TEGANGAN PLN");
digitalWrite(gon, HIGH); //kontraktor gst of
digitalWrite(gstr, HIGH) ; // stater of
digitalWrite(pon, LOW) ; //kontraktor listrik on

}

}

else
{
lcd.clear();
lcd.setCursor (0,0);
lcd.print("TEGANGAN OFF");
digitalWrite(gstb, HIGH) ;

if(digitalRead(Gsen) == HIGH) //jemset of
{

digitalWrite(pon, HIGH);
digitalWrite(gon, HIGH);

digitalWrite(gstb, HIGH) ;
startter1();
reset();

}
else

{

digitalWrite(pon,HIGH);
digitalWrite(gon, LOW);
digitalWrite(gstr, HIGH) ;
digitalWrite(gstb, HIGH);
lcd.clear();
lcd.setCursor (0,0);
lcd.print("TEGANGAN GENSET");

}

}

}

Hello and Welcome.
No one minds that your English is not good, however, there are instructions for using this forum that makes it easier for us to help you. Before you do anything else please take a moment to read General guidance and
How to use this forum
Especially item #7 on posting code.

You have very excessive delays in you code.

Please study blink without delay, which is in the examples in the IDE under digital and apply the lessons learnt to your code.
Also study
Using millis for timing
Demonstration for several things at the same time
And apply what you learn to your code.

What is "ATS"?

johnwasser:
What is "ATS"?

They sell tyres ATS