david_2018:
See what kind of signal levels you get using this modified version of your sketch. I've removed all the servo.detach instructions, servo's like to have a continuous signal to hold their position correctly.
#include <Servo.h>
//constants
const byte InputPins[] = {11, 12, 13, A0, A1, A2, A3, A4};
const byte NrServos = sizeof(InputPins);
const byte ServoPins[NrServos] = {3, 4, 5, 6, 7, 8, 9, 10};
const byte EndPositions[2] = {75, 105};
const byte BounceAngles[] = {7, 0, 3, 0, 1};
const byte MovementDelay = 30;
const byte BounceDelay = 180;
//Variables
Servo servo[NrServos];
bool previousButtonStates[NrServos];
void setup() {
for (byte i = 0; i < NrServos; i++) {
pinMode(InputPins[i], INPUT); // set pins to INPUT
servo[i].attach(ServoPins[i]);
servo[i].write(EndPositions[0]); // move servo to DOWN position
delay(2 * BounceDelay);
//servo.detach(); //no need to detach servo
}
}
void loop() {
for (byte i = 0; i < NrServos; i++) {
//const bool State = digitalRead(InputPins[i]); //should not be declared as a constant
bool State = digitalRead(InputPins[i]);
if (State != previousButtonStates[i]) {
previousButtonStates[i] = State;
//servo.attach(ServoPins[i]); // not needed, servo was not detached
for (byte pos = EndPositions[!State]; pos != EndPositions[State];(State ? pos++ : pos--))
{
servo[i].write(pos); // move servo to position in variable 'pos'
delay(MovementDelay); // wait for the servo to reach the position
}
//make the servo 'bounce'
for (byte n = 0; n < sizeof(BounceAngles); n++) {
servo[i].write(EndPositions[State] + (State ? -1 : +1) * BounceAngles[n]);
delay(BounceDelay);
}
//servo.detach(); //no need to detach servo
}
}
}
I uploaded this sketch to my test board and found that the signal levels are in fact slightly different. I no longer see the 5v high on pins 4 & 5, instead on power up there is a tiny (< 1v) signal which then got to 3v and stays there. When I operate the pin, I see a rise in the voltage to approx 3.8v. The servo operation seems unaffected by these changes BUT I still see a power-up "twitch" when the 10k resistor is removed.
Tomorrow I will upload this sketch to the problem board with 6 servos and observe the results.
Thanks for the help so far
David