#include Servo myservo; int angle = 0; void setup() { myservo.attach(2); // initialise the pin number } void loop() { myservo.write(angle); // set position delay(50); angle++; Serial.println(myservo.read()); //read position if(angle>179) //set a loop angle = 0; }