#include <Servo.h> Servo myservo; void setup() { myservo.attach(9); myservo.write(90); // set servo to mid-point Serial.begin(115200); } void loop() { for (int i = 90; i < 180; i++) {myservo.write(i);delay(5);Serial.println(i);} delay(1000); for (int i = 180; i > 90; i--) {myservo.write(i);delay(5);Serial.println(i);} for (int i = 90; i > 0; i--) {myservo.write(i);delay(5);Serial.println(i);} delay(1000); for (int i = 0; i < 90; i++) {myservo.write(i);delay(5);Serial.println(i);} }