Code to move the servo motor

And even shorter :wink:

#include <Servo.h>
Servo myservo;
byte n = 0;
unsigned long prMillis;
void setup()
{
    myservo.attach(2); //signal line of Servi is with DPin-9
    myservo.write(0);  //initial position of Servo at 0 degrees.
}

void loop()
{
    if (millis() - prMillis > 1000UL)
    {
        prMillis += 1000UL;
        n = n + 2; //1-sec has elapsed; turn servo by 2 degrees
        myservo.write(n);
        if (n >= 180)   //Servo has reached at 180 degrees position; reset to 0 position
        {
            myservo.write(0);
            n = 0;
        }
    }
}

Wether @hg1001 does understand it ... ? But he should give it a try :sunglasses: - understandig how to write non blocking code is one of the most important thing with arduino programming.