#include <Servo.h>
#define SERVO_PIN A0  //将舵机信号线连接到UNOR4 MINIMA的A0 Connect the servo signal line to A0 of UNOR4 MINIMA
Servo myServo;        //实例化一个舵机对象 Instantiate a steering gear object

void setup() {
  pinMode(SERVO_PIN, OUTPUT);  //将舵机连接的引脚设为输出模式 Set the servo connected pin to output mode
  myServo.attach(SERVO_PIN);   //设置舵机对象 Set the steering gear object
}

void loop() {
  //让舵机从180度转到0度 Let the steering gear turn from 180 to 0 degrees
  for (int angle = 180; angle >= 0; angle--) {
    myServo.write(angle);
    delay(5);
  }
  
  //让舵机从0度转到180度 Let the steering gear turn from 0 to 180 degrees
  for (int angle = 0; angle <= 180; angle++) {
    myServo.write(angle);
    delay(5);  //等待一小段时间，使舵机有足够的时间运动到下一个角度
  }

}
