// Create an array to hold 15 buttons pins
const int buttonPins[15] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 23, 25, 27};
void setup() {
Serial.begin(9600);
// Set each button pin as an input with pull up resistor
for (int i = 0; i < 15; i++) {
pinMode(buttonPins[i], INPUT_PULLUP);
}
}
void loop() {
// Loop over all buttons and if any button is pressed, print its pin number
for (int i = 0; i < 15; i++) {
if (digitalRead(buttonPins[i]) == LOW) { // Button pressed
Serial.print("Button pressed on pin: ");
Serial.println(buttonPins[i]);
delay(200); // Debounce delay
}
}
}