how to use delay time

sorry, I'm a beginner
and I, would like to ask for help would sketch that
I have made the correction can be run time,
delay time is not appropriate as it is in the write
sorry, I am not fluent in English

const int signalPln = 2;
const int signalGzt = 4;
const int reportPln = 3;
const int reportGzt = 5;
const int reportGzton = 6;

const int plnOn = 22;
const int gztOn = 23;
const int gztStb = 24;
const int gztStar = 25;
const int alaram = 26;

int pln = 0;
int gzt = 0;
int statusPln = 0;
int statusGzt = 0;
int statusGzton = 0;

void setup() {
pinMode (signalPln, INPUT);
pinMode (signalGzt, INPUT);
pinMode (reportPln, INPUT);
pinMode (reportGzt, INPUT);
pinMode (reportGzton, INPUT);
pinMode (plnOn, OUTPUT); // Kontaktor pln 22
pinMode (gztOn, OUTPUT); // kontaktor Gzt 23
pinMode (gztStb, OUTPUT); // 24
pinMode (gztStar, OUTPUT); // 25
pinMode (alaram, OUTPUT); // put your setup code here, to run once:

}

void loop() {
pln = digitalRead(signalPln); //2
gzt = digitalRead(signalGzt); //3
statusPln = digitalRead(reportPln); //4
statusGzt = digitalRead(reportGzt); //5
statusGzton = digitalRead(reportGzton);

if (pln == HIGH)
{
if (gzt == LOW)
{delay(120000);
digitalWrite (plnOn, HIGH);
digitalWrite (gztStar, LOW);
delay(300000);
digitalWrite (gztStb, LOW);
}
if (gzt == HIGH)

digitalWrite (gztOn, LOW);}// beban gzt mati
if (statusGzt == LOW)
{delay (5000);
digitalWrite (plnOn, HIGH); // beban pln hidup
delay(3000);
digitalWrite (gztStb, LOW);
}delay(20);
}
else
{
digitalWrite (gztStb, HIGH);
delay(5000);
digitalWrite (gztStar, HIGH);
if (gzt == HIGH)
{
digitalWrite (gztStar, LOW);
digitalWrite (plnOn, LOW);
if (statusPln == LOW)
{

delay (5000);
digitalWrite (gztOn, HIGH);
}}}

}
Pleas HELP ME :confused:

Hi Hesly, welcome to this forum.

You should avoid using delay() as much as possible, while running delay() your arduino does nothing else as waiting.

Check the blink without delay example of the IDE, examples -> 2 -> BlinkWithoutdelay.

When an arduino is powered or reset it starts 2 timers, millis() and micros(), you can use those to drive time related events, while being able to do other things as waiting as well.

sorry, I'm a beginner

Then you should read the "how to use this forum sticky" it tells you how to ask a question and how to post code correctly.

Pleas HELP ME

Help you do what?

You have to explain what you want the sketch to do and what it is doing at the moment.

I have made the correction can be run time,
delay time is not appropriate as it is in the write

Sorry but the words do not make any sense to me.

I think that Hesly's native language is probably Indonesian or something similar. So please excuse his bad English.

To Hesly:
When you post code, please post it like this:

const int signalPln = 2;
const int signalGzt = 4;
const int reportPln = 3;
const int reportGzt = 5;
const int reportGzton = 6;

const int plnOn = 22;
const int gztOn = 23;
const int gztStb = 24;
const int gztStar = 25;
const int alaram = 26;

int pln = 0;
int gzt = 0;
int statusPln = 0;
int statusGzt = 0;
int statusGzton = 0;



void setup() {
  pinMode (signalPln, INPUT);
  pinMode (signalGzt, INPUT);
  pinMode (reportPln, INPUT);
  pinMode (reportGzt, INPUT);
  pinMode (reportGzton, INPUT);
  pinMode (plnOn, OUTPUT); // Kontaktor pln 22
  pinMode (gztOn, OUTPUT); // kontaktor Gzt  23
  pinMode (gztStb, OUTPUT);  //  24
  pinMode (gztStar, OUTPUT); // 25
  pinMode (alaram, OUTPUT);  
}

void loop() {
  pln = digitalRead(signalPln); //2
  gzt = digitalRead(signalGzt); //3
  statusPln = digitalRead(reportPln); //4
  statusGzt = digitalRead(reportGzt); //5
  statusGzton = digitalRead(reportGzton);
 
  if (pln == HIGH) {
    if (gzt == LOW) {
      delay(120000);
      digitalWrite (plnOn, HIGH);
      digitalWrite (gztStar, LOW);
      delay(300000);
      digitalWrite (gztStb, LOW);
    }
    if (gzt == HIGH) digitalWrite (gztOn, LOW); // beban gzt mati
  } 
  if (statusGzt == LOW) {
    delay (5000);
    digitalWrite (plnOn, HIGH); // beban pln hidup
    delay(3000);
    digitalWrite (gztStb, LOW);
  }
  delay(20);
  }
  else {
    digitalWrite (gztStb, HIGH);
    delay(5000);
    digitalWrite (gztStar, HIGH);
    if (gzt == HIGH) {
      digitalWrite (gztStar, LOW);
      digitalWrite (plnOn, LOW); 
      if (statusPln == LOW) {
        delay (5000);
        digitalWrite (gztOn, HIGH);
      }
    }
  }
}

Also, what exactly is this supposed to do? What does "pln" mean, and what does "gzt" mean?

I sure this would be of benefit to you:
http://forum.arduino.cc/index.php?topic=223286.0

Thank Mr Simpson_Jr
the use of delay() remains a problem I

Thank for all responses

@Hesly
What happens here:

unsigned long lastMillis;

void setup() 
{
  pinMode(13, OUTPUT);
}

void loop()
{
  if(millis() - lastMillis >= 120000UL)
  { 
    digitalWrite(13,!digitalRead(13));
    lastMillis = millis();
  }
}

@LarryD

unsigned long lastMillis;

You probably meant:

unsigned long lastMillis = 0;

Global variables are cleared at compile/reset time if they are not initialized in your declaration.