Serial at 9600 baudTap a part to see what it does.
Tap the parts to see what each one does. A teaching simulation, not a circuit simulator.
Build it step by step
0 of 4 doneTwo buttons
One at each end of the breadboard, D2 and D3 to GND.
Three LEDs
Green D9, red D10, yellow D11, each through 220 Ω.
Buzzer
D8.
Play
Upload, open the serial monitor, and wait for green.
How do you build a two-player reaction game?
After a random wait the green light comes on. The first player to press their button wins; pressing early is a foul. Times show in the serial monitor. You need Arduino Uno R3, Tactile push button 6 mm × 2, LED 5 mm green, LED 5 mm red, LED 5 mm yellow, Resistor 220 Ω × 3, Active buzzer 5 V and Breadboard 830 Tie Points. It takes 4 steps and about 40 minutes.
- Level
- Beginner
- Time
- About 40 min
- Parts
- 8
Parts list
- Development BoardsBuyArduino Uno R3 × 1
- SwitchesBuy
- SemiconductorsBuyLED 5 mm green × 1
- SemiconductorsBuyLED 5 mm red × 1
- SemiconductorsBuyLED 5 mm yellow × 1
- PassivesBuyResistor 220 Ω × 3
- Motors & ActuatorsBuy
- PrototypingBuy
Tick what you already own. It saves to My Garage, so “Build with what I have” knows.
Wiring
| From | To | Why |
|---|---|---|
| Player 1 button | D2 to GND | INPUT_PULLUP |
| Player 2 button | D3 to GND | INPUT_PULLUP |
| D9 → 220 Ω → green LED | Go light | |
| D10 / D11 → 220 Ω → red / yellow LED | Player 1 / Player 2 winner light | |
| Buzzer | D8 to GND | Start beep |
Code
No libraries. The active buzzer simply beeps; tone() still turns it on and off. Typical reaction times are 200 to 300 ms.
Runs on a virtual Arduino Uno in your browser, with sliders for the sensors. Happy with it? Verify and upload to your real board from the same page (Chrome or Edge on a computer).
const int P1 = 2, P2 = 3, GO = 9, L1 = 10, L2 = 11, BUZZ = 8;
void setup() {
for (int p : {GO, L1, L2, BUZZ}) pinMode(p, OUTPUT);
pinMode(P1, INPUT_PULLUP); pinMode(P2, INPUT_PULLUP);
Serial.begin(9600);
randomSeed(analogRead(A0));
}
void loop() {
digitalWrite(L1, LOW); digitalWrite(L2, LOW);
Serial.println("Get ready...");
unsigned long wait = millis() + random(2000, 6000);
while (millis() < wait) {
if (!digitalRead(P1)) { Serial.println("Foul by player 1"); digitalWrite(L2, HIGH); delay(2000); return; }
if (!digitalRead(P2)) { Serial.println("Foul by player 2"); digitalWrite(L1, HIGH); delay(2000); return; }
}
digitalWrite(GO, HIGH); tone(BUZZ, 1000, 80);
unsigned long start = millis();
while (digitalRead(P1) && digitalRead(P2)) {}
unsigned long ms = millis() - start;
bool one = !digitalRead(P1);
digitalWrite(GO, LOW);
digitalWrite(one ? L1 : L2, HIGH);
Serial.print(one ? "Player 1" : "Player 2"); Serial.print(" wins in "); Serial.print(ms); Serial.println(" ms");
delay(3000);
}What the serial monitor should show
Open the serial monitor at the baud rate in the code. This is what our simulator prints for a virtual Arduino Uno with its sensors at their default values. Your numbers will follow your real readings, but the format should match.
Get ready...
Test checklist
What you should see at each check. If a reading is far off, stop and use the troubleshooting list.
| Check | Expected |
|---|---|
| Wait for green, press | Your light comes on, time prints |
| Press before green | Foul message, the other player's light comes on |
| Ten rounds | Waits vary between 2 and 6 s |
If it does not work
Always player 1
Player 2's button not on D3, or it reads LOW constantly.
Wins with 0 ms
A stuck-down button: check it spans the gap.
Same wait every time
Leave A0 unconnected so randomSeed gets noise.
Still stuck? Find the fault step by step with your multimeter →
Common questions
What parts do I need for the two-player reaction game?
Arduino Uno R3, Tactile push button 6 mm × 2, LED 5 mm green, LED 5 mm red, LED 5 mm yellow, Resistor 220 Ω × 3, Active buzzer 5 V and Breadboard 830 Tie Points.
How long does the two-player reaction game take to build?
About 40 minutes for a beginner maker, in 4 steps.
How do I know the two-player reaction game works?
Wait for green, press: Your light comes on, time prints. Press before green: Foul message, the other player's light comes on. Ten rounds: Waits vary between 2 and 6 s.
Always player 1: what should I check?
Player 2's button not on D3, or it reads LOW constantly.
Wins with 0 ms: what should I check?
A stuck-down button: check it spans the gap.
Same wait every time: what should I check?
Leave A0 unconnected so randomSeed gets noise.
