I have a points control centre (turn-outs in the US) to control 22 servo motors. Associated with this are 19 pushbuttons that I am trying to assign a pin to using an array.
int pbPin[] ={0,1, 2, 3, 4, 5, 6, 7, 8, 9, 14, 15, 16, 17, 18, 19, 20, 21, 22};
As you can see there is no connection to pin 10 - 13,
Here is the setup:
// set pbPins to input
for (int x =0; x <19; x++){
pinMode(pbPin[x], INPUT_PULLUP);}
and here is the loop
//loop through pushbuttons
for(int y = 0; y < 19; y++){
buttonState = digitalRead(pbPin[y]);
delay(15);
buttonState = digitalRead(pbPin[y]);
//delay(500);
if (buttonState == LOW) {
//whichButton = y;
Serial.print("Push button ");
Serial.print(y);
Serial.print(" - pin number");
Serial.println(pbPin[y]);
}
}
When I run the serial monitor, all seems to work ok for all the buttons except buttons connected to D0 & D1. See attached screenshot.
I have tried replacing these buttons to make sure it is not just a fault but the problem exists regardless of which buttons I use.
I thought my logic was ok, but obviously I've made some stupid mistake or there is something about the array that I don't understand.
Hope someone out there more experienced than me can throw some light on this.
