How to modify the below code that the motor works (Turns on) for tamount of time

Hi my friend and really thanks for all your efforts.

I tested your code for several times during past two days and just can say again thank you very very very much.

YOUR code worked great even without one single failure and this was amazing since you saw how much time you patiently and kindly spent on it to correct all. Again Thanks

Now may you let me know what the final code without self-checking the system is that the system does not turn right ad left automatically when the power is connected or the serial monitor opened?

Regards