Whack-a-Mole Game


For the mbed mini project, I developed a simple Whack-a-Mole game that uses an ARM microcontroller, six external LEDs, six pushbuttons, and a text LCD. This game was inspired by the popluar arcade game, Whack-a-Mole, where players have to quickly hit moles that would pop up in a random order. For this game, players have to quickly press the buttons matched to certain LEDs that will light up in a random order at different speeds. The number of hits will tally up and the final score will be displayed once the game is over. Each game lasts 30 seconds.



  1. NXP LPC1768 Microcontroller
  2. 16x2 HD44780 Text LCD
  3. 6 External LEDs
  4. 6 Pushbuttons


16x2 HD44780 Text LCD

Pins 15 and 16 are needed for the backlight on the LCD and were not used in this project. Pins 7 - 10 are not connected too.

p2 (VCC)VU
p3 (VO)GND, via 1k resistor
p4 (RS)p15
p5 (RW)GND
p6 (E)p16

External LEDS

The external LEDs are wired to pins 5 - 8, 10, and 11 on the mbed. 100 Ohm pullup resistors are connected in series to each LED.


The pushbuttons are wired to pins 21 - 26 on the mbed.



Import programLab_4_WhackMole

A simple Whack-a-Mole game using LEDs and pushbuttons

Further Implementation

  • Add a start menu which would allow the player to select different difficulty levels.
  • Add a speaker to play music during the game and to play certain sounds when the "mole" is "hit".
  • Increase the amount of LEDs
  • Implement a proper randomized system. The rand() function will randomly select an array of values only once. Every time the game is reset, the rand() function just picks the same string of numbers. I would like to implement a random method that actually selects a different set of values on each reset.

Please log in to post comments.