Im not sure the title is accurate but what im trying to do is call servos like i would any other variable.
For example.
for(int i=0; i<N_SERVOS; i++) {
//
// instead of going
servo_0.write(pos);
servo_1.write(pos);
servo_2.write(pos);
essentially i would like to be able to write
servo_.write(pos); How would you advanced users do such a method? Hope im making myself clear. Any help would be appreciated, thanks!
The "Servo_1" is just a variable of type "Servo", so you should be able to do everything with it that you can do with any other variable. The following snippet of code compiles without any errors; I'm not immediately able to test it with real servos...
#include <Servo.h>
Servo SArray[5]; // We have 5 servos
byte servoPins[5] = { 4, 5, 8, 9, 10 }; // attached to assort pins
void setup()
{
for (byte i=0; i < 5; i++) {
SArray[i].attach(servoPins[i]);
}
}