Code to move the servo motor

That's the same as
delay(1000);
Why making it such complicated? Or use millis() the right way.