remove delay operation

Please provide comment and possible direction.
I am trying to replace the “delay” function in the following sketch, with something else (not sure with what). This operation work great if only one switch (IR) trigger function is used. When I add the second switch (IR) trigger the operation slows down.

The goal of the sketch is:
Sequence
IR Detector HIGH (off)
Green LED LOW (on)
Red LED HIGH (off)

IR Detector LOW (on)
Red LED LOW (on)
Green LED HIGH (off)

Once IR Detector turns HIGH (off)
Red LED HIGH (Off)
Green LED Flashes for 10 seconds
Green LED LOW (on)
Start at top of sequence

//BMK
// 1-30-2019
// green_red_block_signal

int ledRed1 = 10;
int ledGreen1 = 8;
int ledRed2 = 11;
int ledGreen2 = 7;

int ir1 = 3;
int ir2 = 4;

int buttonStateir1 = 0;
int buttonStateir2 = 1;
int switchValue1; // a variable to keep track of when switch is pressed
int switchValue2; // a variable to keep track of when switch is pressed
int counter1 = 0; //int counter1 Value;
int counter2 = 0; //int counter2 Value;

void setup() {
//Signal tower 1
Serial.begin(9600); // Use serial for debugging
// initialize for ir1 detector 1:
pinMode (ledRed1, OUTPUT);
pinMode (ledGreen1, OUTPUT);
digitalWrite(ir1, LOW); // sets the default (unpressed) state of ir1 to LOW

// initialize the pushbutton pin as an input:
pinMode(ir1, INPUT_PULLUP);

// initialize for ir2 detector 2:
pinMode (ledRed2, OUTPUT);
pinMode (ledGreen2, OUTPUT);
digitalWrite(ir2, LOW); // sets the default (unpressed) state of ir1 to LOW

// initialize the pushbutton pin as an input:
pinMode(ir2, INPUT_PULLUP);
}

void ir1On()
{
digitalWrite (ledGreen1, HIGH);
digitalWrite(ledRed1, LOW);
}

void ir1Off()
{
digitalWrite (ledGreen1, LOW);
digitalWrite(ledRed1, HIGH);

switchValue1 = digitalRead(ir1); // check to see if the switch is pressed
if ((switchValue1 == HIGH) && (counter1 <= 10)) { // if the switch is pressed then,
digitalWrite(ledGreen1, HIGH); // turn the LED off
delay(500); // wait for a 1/2 second
digitalWrite(ledGreen1, LOW); // turn the LED on
delay(500); // wait for a 1/2 second
counter1++;
}
if (switchValue1 == LOW)
{
counter1 = 0;
}
}

// signal tower 2
void ir2On()
{
digitalWrite (ledGreen2, HIGH);
digitalWrite(ledRed2, LOW);
}

void ir2Off()
{
digitalWrite (ledGreen2, LOW);
digitalWrite(ledRed2, HIGH);

switchValue2 = digitalRead(ir2); // check to see if the switch is pressed
if ((switchValue2 == HIGH) && (counter2 <= 10)) { // if the switch is pressed then,
digitalWrite(ledGreen2, HIGH); // turn the LED off
delay(500); // wait for a 1/2 second
digitalWrite(ledGreen2, LOW); // turn the LED on
delay(500); // wait for a 1/2 second
counter2 ++;
}
if (switchValue2 == LOW)
{
counter2 = 0;
}
}

void loop() {
void ir1On();
void ir1Off();
void ir2On();
void ir2Off();

// signal tower 1
// put your main code here, to run repeatedly:
// ir1 Signal Tower 1 Control

// read the state of the pushbutton value:
buttonStateir1 = digitalRead(ir1);

// check if the pushbutton is pressed. If it is, the buttonState is LOW:
if (buttonStateir1 == HIGH)
{
// ir1 detector OFF:
ir1Off();
}
else
{
// ir1 detector ON:
ir1On();
}

// signal tower 2
// ir2 Signal Tower 2 Control

// read the state of the pushbutton value:
buttonStateir2 = digitalRead(ir2);

// check if the pushbutton is pressed. If it is, the buttonState is LOW:
if (buttonStateir2 == HIGH)
{
// ir2 detector OFF:
ir2Off();
}
else
{
// ir2 detector ON:
ir2On();
}
}

Take a look at the BlinkWithoutDelay example sketch, it shows you how you can manage non-blocking waits.

If you post code always use code tags!

The demo Several Things at a Time is an extended example of BWoD and illustrates the use of millis() to manage timing without blocking. It may help with understanding the technique.

Have a look at Using millis() for timing. A beginners guide if you need more explanation.

...R

void loop() {
 void ir1On();
  void ir1Off();
  void ir2On();
  void ir2Off();

Looks like you’ve got some basics to learn as well. Are those function prototypes in the wrong place? Or were you trying to call functions? When you call digitalWrite do you write “void” in front of it?