OK, to be clear, that's not real code, yet
I guess that I have to put it in a for cycle
No. And no switch/case either. You are only doing one of the ten cases in your current switch.
The value of X in the pseudo-code would just be
searchButton(button)
Here's that section of code closer to real code:
// First we need the bidder names. At the top of the sketch:
String bidderName[10] = {
"Pino",
"Manuel",
"Luca",
"Giuseppe",
"Simone",
"Danilo",
"Daniele",
"Mario",
"Pino",
"Manuel"
};
// And the button addresses (pin numbers). At the top of the sketch:
const int BUTTON_PIN[10] = {2, 3, 28, 29, 30, 31, 32, 33, 34, 35};
// And the LED pins. Yes, at the top of the sketch:
const int LED_PIN[10] = {13, 8, 20, 21, 22, 23, 24, 25, 26, 27};
//
// And, finally, we can write (replacing your entire switch/case )
//
int theWinner = searchButton(button);
winner = bidderName[theWinner];
lastBidder = BUTTON_PINS[theWinner];
Serial.println(String("Actual winner: ") + winner);
digitalWrite(LED_PIN[theWinner], HIGH);
I can't test this, and I don't use Capital S Strings (and neither should you, for much longer), so I hope an array of them works like it should, I would bet it's fine.
Go to your favorite learning source and look into arrays and indexing in C/C++ and see if you can make sense of the above.
I reiterate - any time you are copy, pasting and editing code, or have variable names made by appending a digit to a name, like cat_0, cat_1, cat_2… you should get a clue that an array would be useful.
HTH and see you on the learning curve.
a7
