Robot Pac-Man with Raspberry Pi

By Lucy Hattersley. Posted

When video games began to flourish in the seventies and eighties, 15-year-old Emanuele Coletta had not even been born. But when he and his pals caught up with the titles they had missed thanks to their parents’ collective love of retro gaming, they were soon champing at the bit to produce something of their own.

The result was a ‘real-life’ version of Pac-Man, Namco’s classic 1980 pellet-guzzling arcade game. They created 3D-printed robot renditions of the main character and the familiar four ghosts and they replaced the Pac-Dots of the original game’s maze with lights that turn off when the yellow chomper moves over them.

This article first appeared in The MagPi 66 and was written by David Crookes. Click here to download a copy of The MagPi 66


 A magnet beneath the main character interacts with reed switches as it passes over them

Project Showcase: 3D Robot Pac-Man game

“The idea was to make something funny that no one had made before to let us learn and apply new technologies,” explains Emanuele. But at the same time, they added their own little twist.

In the single-player video game, Pac-Man has to eat up all of the Pac-Dots and avoid the ghosts, each of which moves automatically. In what became 3D Pac Robot Man, however, four players control the ghosts. “The aim is for the main character to escape from the others without getting caught, but for the others to try and catch it,” says Emanuele. Suddenly their Pac-Man game became a five-player romp.

Initially, the friends – along with their dads – concentrated on making the playing board out of wood, laser-cutting the various pieces to form the maze. They then attached lots of small boards containing LEDs and reed switches beneath the gaming field and connected them to an Arduino Mini. “Assembling the LED boards – which we made ourselves – and connecting them with bigger boards underneath the field was the easiest but longest part,” Emanuele recalls.
With that in place, they could turn their attention to the characters – the shells and bases of which were designed by the team and 3D printed. Each one contains an Arduino Uno board. “There is also a magnet under the main character,” says Emanuele. By connecting the robots to 3D-printed joysticks containing a board created by one of the team and an Arduino Nano, they could be moved around the maze. “The joystick boards communicate with the robots through radio frequencies at 2.4GHz,” Emanuele continues.

It is at this point that the Raspberry Pi comes into play. When the main character moves, the Arduino Mini understands which reed switch is activated and it can figure which LED to turn off. Points are awarded for each light that is ‘eaten’ and this information, along with details about the game state, is passed to the Pi.

“I wrote a little application in Java which allows people to see the score, the high score and the game state on a monitor,” Emanuele tells us, having used an open-source library called RXTX and the Arduino Playground tutorial to establish the serial connection between the Arduino and Pi. “It also plays the original sounds of the game to give the whole thing a sense of being real and to make people understand what we made.”

It was then a matter of encouraging players to get stuck in, with the build unveiled at Maker Faire Rome. “If the main character gets caught, the catcher wins, but if the main character escapes then it wins.” As expected, the game went down a storm. “People seemed to like our game because they could challenge each other,” Emanuele enthuses. “It was beautiful to see people enjoying their time with something we had made.”

See also:

Galaga Pi

Retro gaming on a Raspberry Pi with Lakka and NOOBS

Step-01 Getting inspiration

Pac-Man is one of gaming’s most recognised icons and the game involves eating dots, avoiding ghosts (Blinky, Pinky, Inky, and Clyde), and amassing points. It inspired Emanuele’s father, Carlo, to create a real-life version.

Step-02 Being spot on

The initial prototype was a metre-square in size, but the aim was the same: to produce a challenging real-life game. The boards containing the LEDs had to be precisely laid out underneath.

Step-03 Invite others along

Since 3D Pac Robot Man was designed to be multiplayer, players also control the ghosts (unlike in Pac-Man where they move automatically). The 3D-printed controllers, made from laser-cut acrylic, show what’s being controlled.

From The MagPi store