#include <Servo.h>
Servo a, b, c, d;
int data[5] = {0, 45, 90, 135, 180};
void setup() {
a.attach(11); // base 伺服电机连接引脚11 电机代号'b'
b.attach(10); // rArm 伺服电机连接引脚10 电机代号'r'
c.attach(9); // fArm 伺服电机连接引脚9 电机代号'f'
d.attach(6); // claw 伺服电机连接引脚6 电机代号'c'
}
void loop() {
for (int i = 0; i <= 4; i++){
a.write(data[i]);
delay(100);
b.write(data[i]);
delay(100);
c.write(data[i]);
delay(100);
d.write(data[i]);
delay(100);
}
for (int i = 4; i >= 0; i--){
a.write(data[i]);
delay(100);
b.write(data[i]);
delay(100);
c.write(data[i]);
delay(100);
d.write(data[i]);
delay(100);
}
}