OLED WHACK-A-MOLE GAME

by DESHBOT in Circuits > Arduino

14 Views, 0 Favorites, 0 Comments

OLED WHACK-A-MOLE GAME

WhatsApp Image 2026-09-25 at 9.55.55 AM.jpeg

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:

  1. D10 → Move the cursor
  2. D12 → Hit the mole

The player has 20 seconds to score as many points as possible.

Downloads

Supplies

des 1.jpeg
uno.jpeg
oled.jpeg

Components Required

ComponentQuantity

Deshbot shield

Arduino Uno/Nano

128×64 OLED Display

Push Buttons

Working Principle

WhatsApp Image 2026-09-25 at 9.55.55 AM.jpeg


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:

TIME:20
TIME:19
TIME:18
...
TIME:0

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:

int mole = 0;

There are four possible positions:

(1) (2)


(3) (4)

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:

cursor++;

if (cursor >= 4) {
cursor = 0;
}

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 (cursor == mole) {
score++;
newMole();
}

If they are equal, the player successfully hits the mole.

If they are different, the player receives a penalty.

OLED Display

The OLED displays:

  1. Game title
  2. Current score
  3. Four mole holes
  4. Current mole
  5. Player cursor
  6. 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.