i want to add incremental rotory encoder in my project

Hello experts.
My self sawan.
I really need help in order to create sketch for my
Desire operation.
Please see my program and edit it for me.
According to further functionality.
In this program i have connect 2ch relay module
And one PNP sensor.
When sensor remain cover with metal relay A. Remain active.
However when sensor remain uncover relay B. Get active. With 5sec delay.
Now i want to add incremental rotory encoder for tracking the position.
As pet block diagram once the push button switch pushed relay C need to activate and same time encoder count 100pulse after 100pulse relay C must deactivate. Rest of the program will be same.
Please see attachment
Please help
Thanks

unsigned long timerStart, timerEnd = 5000;
bool sensorVal= true, previousSensorVal = true;

void setup() {
  pinMode(2, INPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
}

void loop()
{
  sensorVal = digitalRead(2);
  if (sensorVal != previousSensorVal)
  {                               // same as (sensorVal == HIGH)
    previousSensorVal = sensorVal;
    timerStart = millis();
  }   
    if(sensorVal)
    {if(millis() - timerStart > timerEnd)
      digitalWrite(11, LOW);
      
        digitalWrite(12, HIGH);
    }
    else
    {if(millis() - timerStart > timerEnd)
      digitalWrite(12, LOW);
      
        digitalWrite(11, HIGH);
    }
}

jaspalsinghkalsi:
I really need help in order to create sketch for my
Desire operation.
Please see my program and edit it for me.

  1. Please post your code using code tags. No one can edit an image file.
  2. No one will help unless you attempt to make the changes yourself. If you want someone to write code for you there is a forum where you can hire someone to do that.

@jaspalsinghkalsi

Other post/duplicate DELETED
Please do NOT cross post / duplicate as it wastes peoples time and efforts to have more than one post for a single topic.

Continued cross posting could result in a time out from the forum.

Could you take a few moments to Learn How To Use The Forum.
It will help you get the best out of the forum in the future.
Other general help and troubleshooting advice can be found here.

hello experts
my entire program is

unsigned long timerStart, timerEnd = 5000;
bool sensorVal= true, previousSensorVal = true;

void setup() {
  pinMode(2, INPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
}

void loop()
{
  sensorVal = digitalRead(2);
  if (sensorVal != previousSensorVal)
  {                               // same as (sensorVal == HIGH)
    previousSensorVal = sensorVal;
    timerStart = millis();
  }   
    if(sensorVal)
    {if(millis() - timerStart > timerEnd)
      digitalWrite(11, LOW);
      
        digitalWrite(12, HIGH);
    }
    else
    {if(millis() - timerStart > timerEnd)
      digitalWrite(12, LOW);
      
        digitalWrite(11, HIGH);
    }




NOW I WANT TO ADD INCREMENTAL ROTORY ENCODER AND ONE PUSH BUTTON SWITCH IN MY ENTIRE PROJECT.

IN MY ENTIRE PROGRAM MY ARDUINO WORK LIKE THIS.
In this program i have connect 4ch relay module
And one PNP sensor.
When sensor remain cover with metal relay A Remain active.
However when sensor remain uncover relay A Get active. With 5sec delay respectively.

Now i want to add incremental rotory encoder for tracking the position.
As per block diagram once the push button switch pushed, relay c need to activate and same time encoder count 5 RPM  after 5RPM relay C must deactivate. Rest of the program will be same.
Please see attachments.

please send help along with circuit diagram as well.

Please help
Thanks

@jaspalsinghkalsi

You have been warned before about duplicate posting

Take a while to absorb the advice and don't do it again