#include <Servo.h>
#define SERVO_COUNT 2
#define SERVO_Pos 5
Servo servo[SERVO_COUNT]; // array of objects (servos)
byte servo_pins[SERVO_COUNT] = {5, 4};
int servo_stops[SERVO_COUNT][SERVO_Pos] = { // positions to go to
{ 0, 180, 90, 45, 90 },
{ 0, 100, 180, 90, 180 }};
void setup() {
for(int n = 0; n < SERVO_COUNT; n++) {
servo[n].attach(servo_pins[n]); // attach each servo to its pin
}
}
void loop() {
for(int i = 0; i < SERVO_Pos; i++) {
for(int k = 0; k < SERVO_COUNT; k++) {
servo[k].write(servo_stops[k][i]); // update each servo with new position info
}
delay (800);
}
}