Field
Computer Engineering
Education
UT Dallas
Location
Richardson, TX / Open to relocation
Expected
May 2028
Edition
01 / SEP 2026
Exposure

Project record / 14

Whack-a-Mole (Arduino)

embedded reaction-time game on an Arduino Uno with an I2C LCD and scaling difficulty


Project metadata


Overview

A reaction-time game running on an Arduino Uno. Three LEDs, three momentary switches, a 16x2 I2C character LCD, and a reset button. One LED lights at random, the player has a shrinking window to hit the matching switch, and a miss costs a life.


What it does

  • Starts with 3 lives. Each round lights one of three LEDs at random.
  • Hitting the matching switch inside the window scores: red 10, yellow 20, green 30. The payout is tiered, so reaching for the far switch is worth more.
  • Missing the window costs a life. At zero lives the LCD shows GAME OVER, and the reset button restarts at score 0 with 3 lives.
  • The LCD shows running score and lives on two lines. Each successful hit is also logged over serial at 9600 baud.

Architecture

LEDs sit behind current-limiting resistors. Switches are read active high, so each needs a pull-down to ground.


Technical details

Responsive polling instead of a blocking wait. The obvious implementation is delay(2000) and then read the switch once, which registers a hit only at the end of the window and feels broken. Instead the round loops 2000 times with a 1 ms delay(), polling the switch every pass and breaking immediately on a hit, so a press registers within about a millisecond. The remaining window time is discarded on a hit, which is intended.

Parallel constant arrays. LEDS[3] and BUTTON_STATE[3] are indexed by the same random number, so one random(0, 3) picks both the LED to light and the switch to watch. That is what keeps the round logic to a single branch instead of three.

Difficulty ramp. The window starts at 2000 ms. Crossing a score threshold (every 150 points) sets the window to LED_ON_TIME_MSEC / 2, i.e. 1000 ms.

LCD formatting. sprintf into a fixed 16-char buffer with trailing spaces ("Score: %d ") so that a score dropping in digit count does not leave stale characters on the display.


Limitations

See Engineering details above.


Full stack

C++ · Arduino · LiquidCrystal_I2C · I2C



Results

ItemValueBasis
Source lines
133
verified
Digital I/O pins driven
7 (3 LEDs, 4 buttons)
verified
Peripherals over I2C
1 (16x2 character LCD at 0x27)
verified
Course and semester
UTD ECE coursework, Spring 2025
verified
Team
2 people; all firmware solo, hardware build shared
verified