So i want to make a simple game where 4 players have to press their buttons as fast as possible after an LED turns on. the problem is that if I do it like this
for(int i=0;i!=3;i++){ /*Assuming the Buttons are connected to pins 0-3*/
if(digitalRead(i)==LOW){
Serial.print("player");
Serial.println(i+1);
}
}
And more than one button is pressed at exact same time it will always show player 1 as the winner because it's the first one that it tests. Is there any way to check all of the buttons at the same time?
Yes. I just happened to do a delish deepish dive into the mechanism and rules for the Jeopardy ring-in system, there's quite a few little tricks in there.
Well worth a google and a few minutes. And it looks like it would be fun to code.
For example, lockout for early ringing in, 250 ms punishment/disadvantage.
But the OP has the first part just right. It is essential to collect all inputs at the same moment.
direct port manipulation Arduino
will turn up the needed info, it may sound complicate or intimidating, but it is fairly straightforward.
Maybe so. But since it can be done, it should be done. There is still the possibility of a tie, anything to avoid that, and to be able to say there is absolutely no advantage.
I will allow different cable lengths to the switches. Before you laugh read about Wall Street and the advantages that make ppl chase microseconds…
while not enabled
read switches and
start/restart lockout timer on (disable) any that were pressed
if the game master's switch closes
light the GO lamp to indicate OK to ring in
enable the ringing in
forever
read switches and
if an able switch is pressed, break with winner
count down any disabled (locked out) timers if the switch is up
light contestant's podium ring the bell etcetera
There's still a few subtleties I haven't found other than anecdotes about.