#include <Servo.h>
Servo myservo; // 定义Servo对象来控制
int pos = 0; // 角度存储变量
void setup() {
}
void loop() {
myservo.attach(6); // 控制线连接数字9
for (pos = 80; pos <= 110; pos ++) { // 0°到180°
// in steps of 1 degree
myservo.write(pos); // 舵机角度写入
delay(40); // 等待转动到指定角度
}
myservo.write(80); //回到预备点击位置
myservo.detach();//防止舵机烧毁
delay(5000);
}