The problem I have is that only one servo ever responds (the last in series on pin A4). I’m guessing I’m missing something fundamental here but my searches are coming up empty.
I’d recommend following @ScruffR’s advice to use PWM compatible pins. Calling the attach() and detach() methods repetitively isn’t necessary.
Also, here’s some more code to iterate over the servos:
#include "Particle.h"
SYSTEM_MODE(SEMI_AUTOMATIC);
SYSTEM_THREAD(ENABLED);
// Servo array and pins array
Servo servos[5];
uint16_t pins[5] = {A0, A1, A2, A4, A5};
void setup() {
// Attach all servos
for (int i = 0; i < 5; ++i) {
servos[i].attach(pins[i]);
}
}
void loop() {
// Set all servos to 0
for (Servo s : servos) {
s.write(0);
delay(1s);
}
// Set all servos to 180
for (Servo s : servos) {
s.write(180);
delay(1s);
}
}