const int buttonPins[] = {2, 3, 4, 5, 6}; // Taster an diesen Pins angeschlossen

const int numButtons = sizeof(buttonPins) / sizeof(int);

void setup() {

for (int i = 0; i < numButtons; i++) {

pinMode(buttonPins[i], INPUT_PULLUP);

}

Serial.begin(9600);

}

void loop() {

for (int i = 0; i < numButtons; i++) {

if (digitalRead(buttonPins[i]) == LOW) {

Serial.print("Button ");

Serial.print(i);

Serial.println(" pressed");

}

}

delay(100);

}