timer or delay problem

Hello i have a query i am running a code with if else statement i want my if statement to discontinue after a certain time but else should work as long as i am getting the condition.plz guide me

Where is that code? My crystal ball is elseware, working with other matters.

if (mpu6050.getAngleY() < -55 && mpu6050.getAngleY() >= -120)
{
digitalWrite(relay1, LOW);
digitalWrite(relay2, HIGH);
digitalWrite(relay3, HIGH);
digitalWrite(relay4, LOW);
Serial.println("\t Right Posture") ;
lcd.setCursor(0, 0);
lcd.print("Right Posture ");
//lcd.setCursor(0, 1);
//lcd.print(mpu6050.getAngleY());
note: HERE I WANT THAT IF RUNS ONLY FOR 5 SECONDS MAX BUT IN BETWEEN IF THE POSTURE CHANGES ELSE RUNS.

}
else if (mpu6050.getAngleY() >= -55 || mpu6050.getAngleY() <= -120)
{
digitalWrite(relay1, HIGH);
digitalWrite(relay2, LOW);
digitalWrite(relay3, LOW);
digitalWrite(relay4, HIGH);
Serial.println("\t Wrong Posture");
lcd.setCursor(0, 0);
lcd.print("Wrong Posture ");
//lcd.setCursor(0, 1);
//lcd.print(mpu6050.getAngleY());
}

Please post the complete program.

When posting code please use the code button </>
codeButton.png

so your code looks like this

and is easy to copy to a text editor See How to use the Forum

...R