Whac-a-Mole Game with PocketBeagle

Fun, getting started project with PocketBeagle, a Breadboard and components. Build an electronic version of this fun 1970's arcade game.

Categories: Beginner

Whac-A-Mole Game Provides a Great Opportunity for Learning Electronics and Basic Coding using
PocketBeagle powered by Octavo Systems OSD3358-SM System-In-Package(SiP)

We wanted to develop a demonstration to show
how easy it is to get started
building a system and programming using the Octavo Systems OSD3358-SM System-In-Package. What better way than to choose the ultra-tiny and low cost
PocketBeagle to program an arcade style competitive game.

PocketBeagle Whac-A-Mole Game Powered by OSD3558-SM

Whac-A-Mole Game Overview:

Whac-A-Mole styled game
provides a player the opportunity to react quickly to a random LED light up by pressing the corresponding button before the light goes out. If quick enough, the player scores a point. The game provides a "3-2-1" ready signal with two red and one green LED before play begins. The four LEDs (Moles) will then light up randomly. Only one LED will light at a time. The objective of the game is to get the highest possible score in 30 seconds. Play can be one player or many. Turn the potentiometer to increase the difficulty / speed of the LEDs.

Hardware for Whac-A-Mole Game:

Building the Whac-A-Mole game gives the opportunity to connect several LED’s, push buttons, a potentiometer, buzzer and 4 x 7-segment display to a PocketBeagle building a complete I/O system. By using the external headers on the bottom of PocketBeagle to connect to the Breadboard and populating the internal headers on the top of PocketBeagle with female headers we’ve created a flexible configuration for connecting to a Breadboard while still being able to add a
Click Board for future projects

Hardware Layout for PocketBeagle Whac-A-Mole Game

Fritzing Diagram for Hardware Layout:

Follow the instructions in the Fritzing Diagram to build the Whac-A-Mole Game on a Breadboard.

Additional Documentation for PocketBeagle

Go to
for documentation including the System Reference Manual. The SRM contains full Pin identification for the headers as well as full details of features of the PocketBeagle.

Features of the Whac-A-Mole Game:

This game is to press the button corresponding to the light before it goes out. When you do so, your score increases by 1. The objective of the game is to get the highest score possible in 30 seconds.

Game restart switch

  • When the switch goes to one, the countdown to the game start will begin
  • When the switch goes to zero, the score is cleared

Countdown timer

  • The countdown timer will start at 5 and count once per second
  • At 2 seconds it will light up GPIO 0.26
  • At 1 seconds it will light up GPIO 2.0
  • At 0 seconds it will ligth up GPIO 1.16
  • There should be a short buzz on the buzzer for each second and a longer tone at zero

Difficulty level

  • The voltage on the potentiometer will determine the time between lights
  • 1.65V will be 2 second between lights
  • 0 V will be 0.25 second between lights

Instructions for Playing Whac-A-Mole Game:

1) Plug the PocketBeagle microUSB into a power source (either a laptop or 5V USB adapter)

2) Wait for the PocketBeagle to boot

3) Make sure the "Game restart switch" is in the off (ie zero) position

4) If you have set the game to auto-run, then proceed to step 5. Otherwise, move to the directory of the Whack-a-Mole game code.

Run: ./run_whack_a_mole.sh

5) Toggle the "Game restart switch" to the on (ie one) position to begin the game

Code Setup:

All code is attached in the repository. The code is written in Python.

python whack_a_mole.py

Software Setup:

  • Use the latest PocketBeagle image from BeagleBoard.org
  • Unzip the software package in a directory
  • Change the permissions on the run script:

chmod 755 run_whack_a_mole.sh

Run the game:


Please see
for instructions to auto-run the game at boot

# ---------------------------------------------------------

# Auto-run script


# Add to crontab:

#   - In code directory <code>

#     1) mkdir logs

#     2) sudo crontab -e

#     3) @reboot sh <code>/run_whack_a_mole.sh > <code>/logs/cronlog 2>&1


# Reboot the PocketBeagle to then auto-run the program


# ---------------------------------------------------------

Video Demonstration of Whac-A-Mole Game

Getting Started on Octavo Systems OSD3358 Devices

This project gave us a fun way to exemplify how easy it is to get started on Octavo Systems family of OSD3358 System-In-Package devices. For more information and to get started on your own embedded systems products visit us at

Comments are not currently available for this post.