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