I'm trying to work out how to use one function with inputs to be able to control all 12 of my servos, without it being overly bloated.
A cut down version of my code I'm trying to achieve is below.
#include <Servo.h>
Servo servo01;
Servo servo02;
Servo servo03;
Servo servo04;
void setup() {
servo01.attach(11);
servo02.attach(11);
servo03.attach(11);
servo04.attach(11);
}
void ServoMove(int ServoNo, int ServoAdjust) {
"servo" += ServoNo.write(ServoAdjust);
}
void loop() {
ServoMove(01, 0);
}
The above obviously doesn't work but hopefully its clear what I'm trying to achieve. It does work if I have 'servo01.write(ServoAdjust);' instead. But I'm trying to avoid having to write all of them individual functions.
I presume there is an easy solution that my brain just isn't seeing.
Thanks in advance.