How can i stop a loop after 1 minute?
As suggested by Jot in a comment, one way would be to simply do what you want (which takes roughly two seconds per iteration) in a loop, like this:

#include &lt;Servo.h&gt;
Servo myservo;

void setup()
{
  myservo.attach(5);

  for (int i = 0; i &lt; 30; i++)
    {
    myservo.write(45);
    delay(1000);
    myservo.write(125);
    delay(1000); 
    }
}

void loop()
{ 
}




The problem with that is it relies upon knowing how long your delays are, and assumes that the myservo.write() functions take no time. A better method is:

#include &lt;Servo.h&gt;
Servo myservo;

void setup()
{
  myservo.attach(5);

  unsigned long start = millis ();

  while (millis () - start &lt;= 60000)  // for 60 seconds
    {
    myservo.write(45);
    delay(1000);
    myservo.write(125);
    delay(1000); 
    }
}

void loop()
{ 
}


This uses the millis() function call to find out how much time has elapsed, and wait for 60000 milliseconds (60 seconds).



I've put the code into setup because that is where you put things you want done once.