I'm working on a simple code just to test the controls for an Elabs six-servo robot arm. So far it seems simple enough, but I'm getting some errors on my code that I'm not sure how to fix.
#include <Servo.h>
#define servo_number
Servo MyServo[6];
int servoPins[] = {1, 2, 3, 4, 5, 6};
int servoLimitMax[] = {130, 130, 130, 130, 130, 130};
int servoLimitMin[] = {0, 0, 0, 0, 0, 0};
int servoSafeStart[] = {10, 10, 10, 10, 10, 10};
void initServos() {
int i;
for (i=0; i<servo_number; i++);
{
MyServo[i].attach(servoPins[i]); // servo setup
MyServo[i].write(servoSafeStart[i]);
Serial.print(i, DEC);
Serial.print(", ");
}
Serial.println(" ");
}
void setServo(int num, int deg) {
deg = constrain(deg, servoLimitMin[num], servoLimitMax[num]);
MyServo[num].write(deg);
}
void setup() {
initServos();
}
void loop() {
// your code here, sample should move all through 180deg and back
int j;
int i;
int pos;
for (j=0; j<360; j += 20) {
if (j <= 180)
pos = j;
else
pos = 360 - j;
}
for (i=0; i<servo_number; i++) {
setServo(i,pos);
delay(50);
}
}