DIY Simple Arduino Whack-a-Mole Game
by mircemk in Circuits > Electronics
217 Views, 3 Favorites, 0 Comments
DIY Simple Arduino Whack-a-Mole Game

Simple to make Arduino version of the Whack-a-Mole arcade game wich consist a few components.
Supplies

- Arduino Nano R3.
- I2C 16x2 Arduino LCD Display Module
- Buzzer
- Illuminated Pushbutton Switch x 5
- Resistor, 470 ohm x 5
Description


A "Whack-a-Mole" game is a classic arcade-style game where moles pop up randomly from holes, and the player uses a mallet or similar tool to "whack" the moles before they disappear.
The goal is to hit the moles as they appear, to score points while avoiding hitting any other targets. It’s typically timed and the game ends after a certain period, with the player's score displayed. This time I will present you a simple way to make a Whack a mole portable game using an Arduino microcontroller.
In this case, the "moles" will be small buttons with built-in LEDs in different colors. A randomly selected button lights up for a certain time when we have to press it to get a point.
Parts


This project is sponsored by PCBWay. They has all the services you need to create your project at the best price, whether is a scool project, or complex professional project. On PCBWay you can share your experiences, or get inspiration for your next project. They also provide completed Surface mount SMT PCB assemblY service at a best price, and ISO9001 quality control. Visit pcbway.com for more services.
The device is very simple to make and consists of a few components:
- Arduino Nano microcontroller module
- 5 Buttons with built-in Leds with different colours
- LCD display with 16x2 characters and I2C communication protocol
- 5 resistors 470 Ohms
- and Buzzer
Gameplay





The start of the game is indicated on the LCD display and then the buttons start to light up in random order. With each successful press of a button while it is lit, we get a point. If we press the wrong button, we get a negative point and the score is reduced by 1.
Successful or unsuccessful activation of the button (actually catching the mole), as well as other states of the game are signaled by an appropriate sound generated by the buzzer. When the game starts, the first line shows the current score, while the second line shows a bar graph that gradually decreases over time and disappears after exactly thirty seconds, the same time the game lasts. This way we have a visual representation of the remaining time in the game.
To make the game more fun and addictive, over time the duration of the lighting of the corresponding button is reduced, in fact the game is accelerated. At the end of the game, all the buttons flash several times and this is accompanied by appropriate sounds. Then the final score appears on the screen.
After a 5-second break, a new game starts.
I updated the code so that the player has a better overview of the game duration and now the bar instead of 16 horizontal, consists of 80 vertical bars.
Conclusion,schematic and Code

And finally, a quick conclusion. This is a really simple Arduino version of the Whack-a-Mole arcade game made with just a few components, but endlessly fun and addictive, great for testing and practicing reflexes. I installed the device in a suitable box made of PVC board with a thickness of 3 and 5mm and covered with self-adhesive colored wallpaper. Also, for compactness and mobility, the game is powered by 2 lithium batteries (7.4V).