Arduino connected servo takes double the time to start from its initial position

Hi to all, i am a newbie on arduino world, i have written a small piece of code which will move the servo motor every 8sec or 10min or 1hr with increment of 15o angle. at the initial setup loop i have registered the pin no 9 and set the intervalTime variable to 1 (this variable can be increased based on the interval frequency if required additionally more than 8sec) and on loop method i am running a for loop which will power down the arduino for more than 8sec on loop, i am using lowPower.h library for this. now the problem is, when i start the arduino, at the loop runs for first time it sets the servo position to zero angle and on second time the clockPos variable gets increased to 15o but the servo not moves to the 15o angle on the third time the clockPos gets increased to 30 but now the servo moves to 15o angle, i dont know whats happening please help me on this, and have look on my code and please let me know the cause.

#include <LowPower.h>
#include <VarSpeedServo.h>

VarSpeedServo myservo;
int clockPos = 0; //variable for the angle position
int intervalTime = 0; //interval time loop which will equal for minium of 8sec ( 1 = 8sec, 2 = 16sec, and on…)
void setup()
{
pinMode(13, OUTPUT); //just switching off the onboard led
digitalWrite(13, LOW);
intervalTime = 1; //initializing the interval time for 8sec( 1 = 8sec)
}

void loop()
{
//running the loop for the given interval and arduino powerdown till that time
for (int i = 0; i < intervalTime; i += 1)
{
LowPower.powerDown(SLEEP_8S, ADC_OFF, BOD_OFF);
}

//if the servo reaches specified angle of 180 degree we need to reset the clockPos value to zero, so that servo
//can start from zero position
if (clockPos == 180)
{
clockPos = 0;
}
else
{
//if the angle not reached to 180 degree, we are attaching the pin 9 to servo and writting the angle for servo to move
//after servo reaches to the angle, need to increment by 15 degree and detaching the servo.
myservo.attach(9);
myservo.write(clockPos, 30, true);
clockPos = clockPos + 15;
myservo.detach();
}

}

Your code will never set 180 deg. This change fixes that. Why attach/detach ? (attach in setup..if the sleep doesn't ruin it)

//if the servo reaches specified angle of 180 degree we need to reset the clockPos value to zero, so that servo
  //can start from zero position
  if (clockPos > 180)   clockPos = 0;
    //if the angle not reached to 180 degree, we are attaching the pin 9 to servo and writting the angle for servo to move
    //after servo reaches to the angle, need to increment by 15 degree and detaching the servo.
    myservo.attach(9);
    myservo.write(clockPos, 30, true);
    clockPos = clockPos + 15;
    myservo.detach();

Ya that's OK, but I couldn't able to figure out why it's not running as per the interval set at first time, but after the time taken as double to start it goes fine, please help me

Hi anyone, please help me on this, i need it urgent.

My guess is you are detaching and powering down without waiting for a servo pulse to be sent. You'll need something like delay (25) before detaching to guarantee that.

Thanks mark, will try and put you the feedback by tonight.