Agreed with Grumpy Mike. The digital method has no inherent advantage of one person versus another, and it's easy to find out the order that people buzz in. One microsecond is plenty of resolution for all but the most high-stakes million-dollar-prize situations.
Separately, I would advise against using different resistance per switch. First, it will need to be calibrated for a given power source. (I have a shield that uses this scheme for a joystick, and only works when given 5V USB, not 9V battery power.) It's also a lot harder to add more switches in the future.
// the pins connected to each button; expandable
byte buttonPins[5] = { 3, 4, 5, 6, 9 };
byte alreadyPressed[5];
byte orderPressed[5];
#define countof(x) ((sizeof(x)/sizeof(*(x)))
// set up buttons with internal tie-up resistors
void setupButtons() {
for (byte i = 0; i < countof(buttonPins); i++) {
digitalWrite(buttonPins[i], HIGH);
pinMode(buttonPins[i], INPUT);
alreadyPressed[i] = 0xFF;
orderPressed[i] = 0xFF;
}
}
// wait for everyone to release their button (HIGH) for at least 100ms
void waitForFairStart(int duration = 100, int timeout = 5000) {
setupButtons();
int cycles = 0;
int failures = 0;
while (cycles < duration && failures < timeout) {
delay(1);
byte i;
for (i = 0; i < countof(buttonPins); i++) {
if (digitalRead(buttonPins[i]) == LOW)
break;
}
if (i >= countof(buttonPins))
count++;
else
count = 0, failures++;
}
}
// wait for the first to press their button (LOW)
byte waitForFirstHit(int timeout = 5000) {
setupButtons();
long start = millis();
long offset = (start+timeout < start)? timeout*2 : 0;
while (millis()+offset < start+timeout+offset)
for (byte i = 0; i < countof(buttonPins); i++)
if (digitalRead(buttonPins[i]) == LOW)
return i;
return 0xFF;
}
// wait to get order of button presses within timeout
// orderPressed[0] is index of first button pressed, and so on
//
byte waitForAllHits(int timeout = 5000) {
setupButtons();
byte next = 0;
long start = millis();
long offset = (start+timeout < start)? timeout*2 : 0;
while (next < countof(buttonPins) &&
millis()+offset < start+timeout+offset) {
for (byte i = 0; i < countof(buttonPins); i++) {
if (alreadyPressed[i] == 0xFF)
if (digitalRead(buttonPins[i]) == LOW) {
orderPressed[next] = i;
alreadyPressed[next] = i;
next++;
}
}
}
}
return next;
}