Introduction: Gesture-Controlled Pac Man W/ Arduino & Grove Gesture Module

About: Howdy, we are application engineers in Seeed. Sharing projects with the maker community is awesome. Hope you like it XD Seeed is the IoT hardware enabler providing services that empower IoT developers to swift…

Pac-man Pac-man Pac-man! Hahaa! If any of you knows what I am talking about, then you must be old enough to know such an old-fashion arcade game, just like me XD (NO OFFENSE). In fact, I started to play those classic Japanese game since I was a little boy, and right now I still feel interesting about it. Figured that's why I came up with this idea after I spent an afternoon sitting around and then saw my unfinished pizza on the table, that's how them came up with Pac-man as well isn't it ? BTW since I learned about many smart easy-to-use hardware pieces at SeeedStudio, I was wondering if I can combine games and some of these hardware modules to make it more fun to play, so this Pac-man might be good start.

Step 1: How the Game Works

Since I am not a pro in programming, this projects is kind of a challenge to me. But let's think this way: no challenge no fun, isn't it?

Anyway, I want to keep the game as simple as possible.

So here is the How the Game Works:


Of course, there is gonna be a Pac-man, on the display, keeping his big mouth open and close, desperately looking for food (a little red dots/pixel on the screen), it can move

  • forward
  • backward,
  • upward
  • downward


To keep it simple I got rid of the monsters in the game, leaves only the Pac-man and his food.

Before game started, a total time of game and a goal are pre-set. At first the Pac-man moves quite slow, the food randomly appears on the screen. Once the Pac-man touches the food, the food will be digested and a new food arises in somewhere else, meantime the delicious food forces Pac-man to speed up to for even more food.

When the time runs out, you can see if you have lost of won according to the goal you've set.

Step 2: Parts I Used

As I want everyone in the house can see me playing my DIY "Arduino" game Pac-man, I don't want it to be too small. So, the first thing I need is a big screen.

Controller - I used Seeeduino v4.2 an Arduino-compatible board, I consider this as one of the best Arduinos, very stable, easy-to-use, and even quit good looking, comes very handy for most of arduino based projects.

Display - In this case I used 4x Ultrathin 16x32 Red LED Matrix Panel to make a 64x32/307.5mm X 165.8mm LED screen.

Score Indicator - Making a game means there must be a score indicator, so I need to set up an extra display to play the part of counting the scores and timing. In my perspectives an I2C LCD would be a good choice as it won't be interfere with the LED Matrix Panel, which uses SPI interface for data transmission. Also it was easier for me to do the program based on Arduino IDE. I am a newbie in C language BTW (If there are better ways to do it you can comment below so we can discuss about it :)

Game Control - As for the game control, I was thinking about a rather interesting ways to achieve it. So I got rid of the traditional Gamepad or Joystick, instead I chose a very intriguing module - the GROVE - GESTURE. You might not be familiar with it, but trust me, this is truly the most fun of part it - command the Pac-man with different gestures, keep reading and you will know what exactly is this Grove - Gesture and how it works, also there is a video below.

Sound Effect - a simple buzzer could do the work.

Others - If you have access to the resources like 3D printing or laser cutting, you can DIY cases to frame up the hardware pieces.

Step 3: So, What Exactly Is This Grove - Gesture?

OK, official statement:

The sensor on Grove - Gesture is PAJ7620U2 that integrates gesture recognition function with general I2C interface into a single chip. It can recognize 9 basic gestures including move up, move down, move left, move right, etc with a simple swipe of your hand, and these gestures information can be simply accessed via the I2C bus.

My definition:

It is a piece of hardware, and it recognize 9 different hand gestures:

  1. Move Right
  2. Move Left
  3. Move Up
  4. Move Down
  5. Move forward
  6. Move Backward
  7. Circle Clock-wise
  8. Circle-counter Clock-wise
  9. Wave

In this project I only used the first 4 gestures to control the Pac-man, and the circle clock-wise gesture to start the game.

How this module works:

As I know the module integrates sensor array for object extraction, when your hand sweep through the sensor, the gesture information is recognized and stored in the register ban, you can simply access these information via I2C bus.

The detecting range is about 5 - 15 cm, which is good enough in most of gesture controlled projects.

Step 4: Circuit Connections

The circuit connection is shown in the picture I've uploaded here. But again I will make a description below in case some of you have problem see the picture clearly.Be noted that "<===> " represents the wires here.

The connections of the modules with Grove standard interfaces are pretty easy:

Grove Gesture <===> Seeeduino v4.2 【I2C interface】

I2C LCD <===> Seeeduino v4.2 【I2C interface】

Grove - Buzzer<===> Seeeduino v4.2 【D10】

Since the LED Matrix Panel do not have a Grove standard interface, so it going to take some time to figure out which DATA pin on the panel is connected to which digital output on the Seeeduino. But don't worry because I already figured it out for you.

Ultrathin Red LED Matrix Panel One 【RowA】<===> Seeeduino v4.2 【D7】

Ultrathin Red LED Matrix Panel One 【RowB】<===> Seeeduino v4.2 【D6】

Ultrathin Red LED Matrix Panel One 【RowC】<===> Seeeduino v4.2 【D5】

Ultrathin Red LED Matrix Panel One 【RowD】<===> Seeeduino v4.2 【D4】

Ultrathin Red LED Matrix Panel One 【OE】<===> Seeeduino v4.2 【D3】

Ultrathin Red LED Matrix Panel One 【STB】<===> Seeeduino v4.2 【D2】

Ultrathin Red LED Matrix Panel One 【R1】<===> Seeeduino v4.2 【MOSI】

Ultrathin Red LED Matrix Panel One 【CLK】<===> Seeeduino v4.2 【SCK】

Step 5: Design the Case

To not mess up all the wire, I also designed a shell to case up the screen as well as all the electronic components.

You can download the file here.

Step 6: Download the Code

First of all, you can download the code here.

There're some steps to be followed:

  1. When you get to the github page, find a Download ZIP button, click to download the code.
  2. The code you downloaded is not an Arduino library, it's a sketchbook, which is include all the library the project need.
  3. Unzip the file you had downloaded from github, you will get a folder Pac_man-master.
  4. Open your Arduino IDE, click File > Preferences > Sketchbook Location, browse to the folder we had mentioned above - Pac_man. Then click OK to save it.
  5. Close and re-open Arduino IDE, click File > Sketchbook > Pac_Man_Demo, then the main code of this project is open.
  6. Choose the right board (Arduino UNO) and port to upload the code. Refer to the image above.

Step 7: Here We Go!

Now we've set up everything and ready to play!

Step 8: Enjoy the Game

Hope you all like this Pac-man Arduino Game. I know it's a pity not including the classic Pac-man ghosts "Blinky", "Pinky", "Inky" and "CLYDE" in the game. But I think I will keep working on it to make it more. you know, playable.

Once again thank you for reading this instructable, if you like it please put it in your favorite and also, don't forget to follow me for more interesting projects as well XD.

Gaming Contest

Participated in the
Gaming Contest