1. ro
  2. en
06 August 2025

Mole Patrol — Reflexes Under Pressure, Arduino style

Introduction

 

A single LED lights up. A subtle tone tickles your ear. Your fingers have exactly one second to hit the correct button… If you succeed, your score climbs. If not, the game ends with a melody played by a disappointed brass band, and the screen reminds you that vigilance is everything.

Welcome to Mole Patrol — a DIY reflex game powered by an Arduino microcontroller, where fun meets education in a fast-paced, interactive challenge.

Designed as a hands-on project featuring multicolor LEDs, physical buttons, and a TM1637 digital display, Mole Patrol turns your reflexes into a visual and auditory spectacle. The glowing “RED” message at startup isn’t just a word — it’s the game’s identity. With a minimalist yet expressive style, the player is invited to begin by pressing the red button, triggering a dynamic countdown: 3, 2, 1 — accompanied by energetic sound cues. Then the real challenge begins: a random LED lights up, and the player has just one chance to press the matching button in under a second.

The fusion of light, sound, and motion makes this game an ideal platform for developing reaction speed and hand-eye coordination. More than that, Mole Patrol is a practical demonstration of electronics, programmable logic, and physical interaction. It’s perfect for robotics enthusiasts, educators seeking STEM activities, or makers looking to add a clever twist to their personal project collection.

Beyond its simple components — LEDs, buttons, a buzzer, and a microcontroller — the game captures the essence of creative interaction: a clear idea, elegant execution, and an experience that sparks smiles and friendly competition. It’s easy to replicate, simple to customize, and ideal for showcasing at tech fairs, maker expos, or creative clubs.

In the end, Mole Patrole isn’t just a game — it’s a celebration of curiosity, skill in motion, and the joy of bringing ideas to life with microchips and a few lines of code.

 

How the Game Works

 

Mole Patrol begins when the player presses the red button, signaled by a stylized “RED” message on the TM1637 display and the rhythmic blinking of the red LED. This action activates a dynamic countdown — 3, 2, 1 — paired with energetic sound cues, preparing the player for the active game mode.

Each round presents a new challenge: the system randomly lights up one of four colored LEDs — red, yellow, green, or blue — for a brief moment. When the LED lights up, the player must quickly press the corresponding button.

A correct press triggers a confirmation tone, updates the score on the display, and allows the game to continue. A wrong or delayed response ends the game, marked by a descending sound sequence and a flashing visual effect on the final score.

The game’s rhythm is driven by the rapid alternation of LEDs and the pressure of a one-second reaction window. As the score increases, the player is motivated to react faster and stay focused, turning each round into a reflex and coordination workout.

The digital display provides clear, real-time feedback, while sound effects help maintain attention and tension. After each mistake, the system gracefully returns to the “RED” screen, inviting the player to try again and beat their personal best.

 

Game Rules – Mole Patrol

 

1. Starting the Game

The game starts when the player presses the red button, indicated by the “RED” message on the TM1637 display and the blinking red LED. This gesture triggers a dynamic countdown — 3, 2, 1 — accompanied by energetic tones that signal the start of active gameplay.

 

2. Round Mechanics

In each round, the system randomly lights up one of the four colored LEDs — red, yellow, green, or blue — for a short duration (≈1 second). When the LED lights up, the player must quickly press the matching button.

 

3. Response Check

  • Correct response → A confirmation tone plays, the score updates on the display, and the game continues.

  • Incorrect or delayed response → The game ends with a sound sequence and a flashing visual effect showing the final score.

 

4. Timing & Difficulty

Each LED stays lit for approximately one second, requiring fast and accurate reactions. As the score increases, the pace intensifies, turning each round into a high-speed test of visual-motor coordination.

 

5. Feedback & Replay

  • The TM1637 display provides instant feedback, showing the score in real time.

  • Sound and visual effects maintain focus and suspense.

  • After each mistake, the system returns to the “RED” screen, allowing the player to restart and aim for a higher score.

 

 

 

 

🔌 The Circuit Diagram

 

At first glance, the circuit diagram might look intimidating—its lines twisting and turning like a never-ending technical tale. But don’t let appearances discourage you. We’ll walk through it together, step by step, decoding each symbol and uncovering the logic behind the layout. As we place the components onto the breadboard in a clear and intuitive way, you’ll see how quickly confusion turns into curiosity—and curiosity into confidence.

 

 

Wiring Overview: Connecting the Circuit

 

As you can see, the circuit is built from a series of straightforward connections between the Arduino and various components. Each wire has a purpose, and together they form the backbone of the game’s interactive experience. Here's how everything links up:

 

🔴 Red Button & LED

  • Red Button Terminal 1 → Arduino Pin D12

  • Red Button Terminal 2 → Arduino GND

  • Arduino Pin D7 → Resistor R1 (Terminal 1, for Red LED)

  • Resistor R1 (Terminal 2) → Positive (+) leg of Red LED

  • Negative (−) leg of Red LED → Arduino GND

 

🟡 Yellow Button & LED

  • Yellow Button Terminal 1 → Arduino Pin D6

  • Yellow Button Terminal 2 → Arduino GND

  • Arduino Pin D10 → Resistor R2 (Terminal 1, for Yellow LED)

  • Resistor R2 (Terminal 2) → Positive (+) leg of Yellow LED

  • Negative (−) leg of Yellow LED → Arduino GND

 

🟢 Green Button & LED

  • Green Button Terminal 1 → Arduino Pin D8

  • Green Button Terminal 2 → Arduino GND

  • Arduino Pin D4 → Resistor R3 (Terminal 1, for Green LED)

  • Resistor R3 (Terminal 2) → Positive (+) leg of Green LED

  • Negative (−) leg of Green LED → Arduino GND

 

🔵 Blue Button & LED

  • Blue Button Terminal 1 → Arduino Pin D9

  • Blue Button Terminal 2 → Arduino GND

  • Arduino Pin D5 → Resistor R4 (Terminal 1, for Blue LED)

  • Resistor R4 (Terminal 2) → Positive (+) leg of Blue LED

  • Negative (−) leg of Blue LED → Arduino GND

 

🔊 Speaker

  • Positive (+) terminal of Speaker → Arduino Pin D12

  • Negative (−) terminal of Speaker → Arduino GND

 

🖥️ TM1637 Display

  • CLK (Terminal 1) → Arduino Pin D3

  • DIO (Terminal 2) → Arduino Pin D2

  • GND (Terminal 3) → Arduino GND

  • VCC (Terminal 4) → Arduino 5V

 

 

 

Materials Needed

 

  • Arduino Uno or a compatible equivalent board

  • 4 LEDs (preferably 5mm) in different colors: red, yellow, green, and blue

  • 4 momentary push buttons (normally open) that can be mounted on a breadboard

  • 1 four-digit, seven-segment display controlled by a TM1637 driver chip

  • a speaker for sound feedback

  • 1 large breadboard (830 tie-points recommended)

  • Jumper wires for all necessary connections

 

 

 

🛠️ Installing Components on the Breadboard

 

As you’ll notice, the number of electrical connections required is quite manageable. You just need to pay attention to a few key details to ensure everything is set up correctly:

  • LEDs are polarized components, meaning they must be connected in the correct direction. To help guide you, we’ve labeled the legs as A (anode, +) and K (cathode, −). If installed backwards, the LEDs won’t light up.

 

  • Push buttons have four pins arranged in a rectangular layout—not a perfect square. This means they naturally fit into the breadboard in only one orientation, without forcing them.

  • Resistors are non-polarized, so they can be placed in either direction. Their role is to limit current and protect sensitive components, especially the LEDs.

  • The speakers may come with colored wires. If the terminals aren’t marked, remember: the red wire typically indicates the positive side and should be connected to Pin D12, while the black wire goes to GND.

  • Breadboard power rails are grouped in sets of 25 pins along the sides. To ensure consistent voltage across the board, it’s important to bridge the power rails—this keeps the power supply uniform throughout the entire length of the breadboard.

  • If this is your first time using an Arduino board, you can connect everything without worry. A fresh board won’t have any preloaded programs, so there’s no risk of unexpected behavior during setup.

 

 

 

Source Code

 

Before compiling the source code, you’ll need to install a library that enables communication with the 4-digit, 7-segment display powered by the TM1637 driver chip. The library is called “TM1637”, developed by Avishay Orpaz.

To install it:

  • Open the Library Manager in the Arduino IDE

  • Search for “TM1637”

  • Select “TM1637 by Avishay Orpaz”

  • Click “INSTALL”

 

You can download the source code here. The file includes detailed comments explaining nearly every line, making it easy to follow and customize.

 

Note: The link opens a .ino file in a new browser tab. Since most browsers treat it as plain text, you’ll need to save it properly:

  • Press Ctrl + S

  • In the “Save as type” dropdown, choose “All files”

  • Add the .ino extension to the filename (e.g., MolePatrol.ino).  Alternatively, you can copy the entire code (Ctrl + A, then Ctrl + C), open a new sketch in the Arduino IDE, and paste it (Ctrl + V) directly.

 

Once your components are installed on the breadboard, simply upload the code to your Arduino board and enjoy the game! 🎮

 

 

If the game feels too slow or too fast for your taste, simply tweak one line of code inside the main loop() function to fine-tune the timing.

 
while (millis() - startTime < 1000){ 


The value 1000 represents the reaction time — the duration (in milliseconds) during which the LED stays lit and the player must press the correct button. In this case, 1000 milliseconds equals one second. If you want to make the game faster, simply reduce this value.

 

while (millis() - startTime < 800){       //0.8 seconds

while (millis() - startTime < 600){      //0.6 seconds

 

or you can increase the value, for a slow pace game: 

 

while (millis() - startTime < 1200){       //1.2 seconds

 

 

You can also make the game more engaging by adjusting the reaction time dynamically. Instead of using a fixed value like 1000 ms, you can define it as a variable that changes depending on the player's score or current level. This way, the game becomes progressively faster and more challenging as the player improves.

 

int reactionTime = max(400, 1000 - score * 10); // decrease time as score increases  

while (millis() - startTime < reactionTime){

 

 

 

And That’s Not All…

You can take this project to the next level by integrating all components into a custom enclosure. If you have access to a 3D printer, you can design an attractive and ergonomic case tailored to your layout and style.

No 3D printer? No problem — an ABS plastic box, commonly used in electrical installations, is a great alternative. It offers durability, safety, and a clean, professional appearance.

With a proper enclosure, your project gains not only functionality but also a presentation that truly stands out.

Explore the resources and design ideas here...

 

 

 

First Major Update — Version 2.0

 

We've reconfigured the Mole Patrol game, introducing several improvements over the original version. Here's what's new in Version 2.0:

Structured Levels

  • The game now features a fixed number of levels — 50 in total, with progressive difficulty as you advance.

 

Scoring System with Bonuses & Penalties

  • +1 point for each correct response

  • −1 point for each mistake

  • +3 points for every 5 consecutive correct hits

  • +5 points for every 10 consecutive correct hits (total bonus: +8 points)

  • −3 points if the player misses 5 rounds in a row

 

Negative Score Protection

  • Just like in the original version, the score cannot drop below 0, no matter how many mistakes are made.

 

Accuracy Bonus

  • If the player achieves 5 precise hits in a row, they earn an additional +5 bonus points

  • After receiving the bonus, the combo streak is reset

 

Permanent Penalty for Incorrect Presses

  • Any incorrect button press — at any time, including during an active round — results in a −1 point penalty

  • A wrong press does not cancel the positive score earned in the same round, but it adds a separate penalty

 

You can download the source code using this link.

 

Note: The link opens a .ino file in a new browser tab. Since most browsers treat it as plain text, you’ll need to save it properly:

  • Press Ctrl + S

  • In the “Save as type” dropdown, choose “All files”

  • Add the .ino extension to the filename (e.g., MolePatrol.ino).  Alternatively, you can copy the entire code (Ctrl + A, then Ctrl + C), open a new sketch in the Arduino IDE, and paste it (Ctrl + V) directly.

 

 

Second Update — Version 2.1

What’s new in Version 2.1:

 

Timed Gameplay

  • The game now runs for a fixed duration of 60 seconds

 

Dynamic Reaction Time

  • Initial reaction window: up to 1000 ms

  • After 40 seconds: minimum reaction time drops to 400 ms

  • After 50 seconds: minimum reaction time drops further to 320 ms

  • This progressive timing increases difficulty as the clock runs out

 

Display Format

  • The first two digits show the remaining time

  • The last two digits show the current score

 

Scoring

  • Correct response: +1 point

  • Incorrect or delayed response: −1 point

 

Combo Bonuses & Penalties

  • Bonus points for successful streaks

  • Penalties for consecutive misses — carried over from v2.0

 

Final Countdown Alert

  • A warning sound plays during the last 10 seconds to heighten tension and focus

 

You can download the source code using this link.

 

Note: The link opens a .ino file in a new browser tab. Since most browsers treat it as plain text, you’ll need to save it properly:

  • Press Ctrl + S

  • In the “Save as type” dropdown, choose “All files”

  • Add the .ino extension to the filename (e.g., MolePatrol.ino).  Alternatively, you can copy the entire code (Ctrl + A, then Ctrl + C), open a new sketch in the Arduino IDE, and paste it (Ctrl + V) directly.

 

 

Third Update — Version 2.2

Key differences between Version 2.2 and the original release:

 

Fixed Level Count

  • The game now includes 40 levels, with progressive difficulty as the player advances.

 

Starting Score Bonus

  • Players begin the game with 5 points — a welcome bonus to kick things off.

 

Multiple LEDs Challenge

  • Two LEDs lit simultaneously until the score exceeds 40 points:

    • Pressing both correct buttons+2 points

    • Pressing only one correct button+1 point

    • Pressing none or a wrong button−2 points

  • Turbo Mode activates once the score exceeds 40 points, lighting up three LEDs simultaneously:

    • Pressing all three correct buttons+3 points

    • Pressing two correct buttons+2 points

    • Pressing one correct button+1 point

    • Pressing none or a wrong button−3 points

 

Negative Score Protection

  • As in previous versions, the score cannot drop below zero, regardless of mistakes.

 

You can download the source code using this link.

 

Note: The link opens a .ino file in a new browser tab. Since most browsers treat it as plain text, you’ll need to save it properly:

  • Press Ctrl + S

  • In the “Save as type” dropdown, choose “All files”

  • Add the .ino extension to the filename (e.g., MolePatrol.ino).  Alternatively, you can copy the entire code (Ctrl + A, then Ctrl + C), open a new sketch in the Arduino IDE, and paste it (Ctrl + V) directly.

 

 

 

 

Got fast reflexes? Put them to the ultimate test in the Light Speed Challenge — where sharp focus and split-second decisions are everything!

 

 

​​​​​​​

​​​​​​​