OLED WHACK-A-MOLE GAME
The OLED Whack-a-Mole Game is an interactive Arduino-based game in which the player must find and hit the mole as quickly as possible.
The game uses a 128×64 OLED display to show four possible mole positions. The player uses two buttons:
- D10 → Move the cursor
- D12 → Hit the mole
The player has 20 seconds to score as many points as possible.
Downloads
Supplies
Components Required
ComponentQuantity
Deshbot shield
Arduino Uno/Nano
128×64 OLED Display
Push Buttons
Working Principle
The game contains four possible mole positions.
The player controls a cursor that moves between these four positions.
When the player presses the Move button, the cursor moves to the next position.
When the player presses the Hit button, the Arduino checks whether the cursor is currently pointing at the mole.
Correct Hit
If the cursor is on the mole:
Score +1
A new mole position is then selected.
Wrong Hit
If the player hits the wrong position:
Score -1
The score cannot go below zero.
. Game Timer
The game lasts for 20 seconds.
The OLED continuously displays the remaining time:
The Arduino uses the millis() function to measure the game time without needing an external clock module.
. Mole Position
The program stores the current mole position in:
There are four possible positions:
The Arduino randomly selects a new mole position after every correct hit.
The program also makes sure that the new mole is different from the previous position.
. Cursor Movement
The player cursor is controlled using D10.
Every time D10 is pressed, the cursor moves to the next position:
After position 4, it returns to position 1.
Hit Detection
When D12 is pressed, the Arduino compares the cursor position with the mole position.
If they are equal, the player successfully hits the mole.
If they are different, the player receives a penalty.
OLED Display
The OLED displays:
- Game title
- Current score
- Four mole holes
- Current mole
- Player cursor
- Remaining time
The mole is represented by a filled circle, while the cursor is represented by a square around the selected position.
Conclusion
The OLED Whack-a-Mole Game is a fun Arduino project that combines OLED graphics, push-button input, random positioning, timing and score calculation.
The player must quickly move the cursor to the correct mole position and press the hit button. The project demonstrates several important Arduino programming concepts and can be further developed into a more advanced arcade-style game.