Build an Arduino reaction timer
ActivitiesProjects
Use a lamp and button to measure the time between a random signal and a player's response.
Wire an LED and a pushbutton to an Arduino, upload a short sketch, and you have a working tabletop reflex game. Each round begins with a random pause before the LED lights up, and the board counts the milliseconds until you press the button. Because that reading captures the interval between the programmed light signal and the switch input on your specific hardware and code, it serves as a benchmark for comparing trials on that setup. You can keep the build minimal on a breadboard with a single button, expand it into a five-round averaging game with an LCD, or skip the screen and read scores over the Arduino serial monitor.
Three ways to lay out the game
The most compact starter version uses an Arduino Uno, a breadboard, jumper wires, one pushbutton, an LED with a 220 Ω resistor, and a 16×2 LCD. That single button handles both roles: press it to start the round, wait for the light, and press it again as fast as you can to stop the clock.
A multi-round tabletop build splits the controls into separate START and HIT pushbuttons and runs five trials in a row. After you press and release START, each trial waits through a random pause—for example, calling `random(500, 5000)` seeded from analog input 0 (`analogRead(0)`)—turns on the trigger LED, tracks the HIT wait with `millis()`, and displays that trial's time before showing the integer average of all five attempts for ten seconds. One published parts list for that five-round build names an Arduino Micro, two 12 mm pushbuttons, two LEDs, two 10 kΩ resistors, a 16×2 I²C LCD, a three-AAA battery holder, a slide switch, and a soldering iron.
To add a decision element, a choice-reaction build uses three buttons and two LEDs. Pressing a Ready button begins the round; after a random wait—such as `random(2000, 5000)` passed to `delay()`, giving a two-to-five-second pause—one of the two LEDs switches on and you have to press its matching button. Printing the result to the Arduino serial monitor avoids wiring a separate screen, and the sketch can report an incorrect button choice on its own.
Wiring buttons and displays cleanly
Before assembling the full game, testing one LED and one pushbutton by themselves makes it easier to isolate a wiring error from a sketch bug. Arduino's basic Button example uses a pull-down circuit: an LED runs from digital pin 13 through a 220 Ω resistor to ground, the pushbutton connects 5 V to pin 2, and a 10 kΩ resistor ties pin 2 to ground. With pin 2 configured as `INPUT`, the sketch reads `HIGH` when the button is pressed and switches the LED on.
Many reaction-timer sketches use the opposite input mode, configuring button pins with `INPUT_PULLUP`—for instance, assigning START to pin 5, HIT to pin 7, and the trigger LED to pin 9. Because pull-down wiring and `INPUT_PULLUP` expect different physical connections, stick to one input mode across your circuit and code rather than copying a pull-down wiring diagram into an `INPUT_PULLUP` sketch. For the same reason, do not assume parts and wiring from a one-button Uno breadboard layout can be swapped directly into a two-button Micro sketch.
Adding an I²C LCD calls for one extra check between the hardware and the code. Even published builds do not always match their own parts lists—one 16×2 I²C LCD project initializes `LiquidCrystal_I2C` at address `0x23` as 20 columns by 4 rows—so verify your display's actual dimensions, its I²C address, a complete wiring diagram, and the installed `LiquidCrystal_I2C` library before expecting text to appear.
Handling early presses and button bounce in code
Two small software details separate a quick prototype from a fair game. First, check what happens if a player holds the HIT button down before the LED turns on. A simple loop that waits through the random delay, starts the timer, and then pauses only while the HIT input reads high can end immediately on a held button rather than catching the false start. Adding a separate waiting state that rejects an early press and requires the button to be released before the next trial closes that loophole.
Second, pushbuttons can generate brief electrical noise when toggled. Standard debounce code tracks time with `millis()` and requires a minimum delay between accepted state changes—Arduino's Debounce example uses 50 ms—to filter out that chatter. That 50 ms figure belongs to the general demonstration rather than every reaction game: waiting for a confirmed state change before recording the timestamp can alter the reported result, so decide deliberately whether your sketch timestamps the initial transition or waits for a confirmed press.
