#include <Servo.h>
Servo myservo;

void setup() {
  // put your setup code here, to run once:
pinMode(8, OUTPUT);
myservo.attach(4);
}

void loop() {
  // put your main code here, to run repeatedly:

digitalWrite(8, HIGH);
delay(500);
digitalWrite(8, LOW);
delay(500);
for(int i=0;i<180;i++){
  myservo.write(i);
  delay(50);
}
for(int i=180;i>0;i--){
  myservo.write(i);delay(50);
}
}