Pico Pong

By Nicola King. Posted

After discovering that Raspberry Pi Pico can use its Programmable Input/Output (PIO) capability to output a video signal, Nick Bild was inspired to recreate the arcade classic Pong. Not only that, but he’s made it gesture-controlled.

“I love playing old games in RetroPie on my Raspberry Pi 4 with my son Luke,” he tells us, “so when I realised what a perfect fit Pico’s PIO would be for generating a VGA signal, my mind went to a reimagining of one of the greatest games of all time.”

It took Nick about three weeks of nights and weekends to build Pico Pong: “I have a day job, so I have to fit my projects in when I can.”

The difficult part was getting the VGA signal timing just right. “Once I had that locked down, it only took me a couple of hours to code up the Pong algorithm and graphics,” he reveals.

Since Pico’s PIO handles the cycle-intensive process of generating video, this leaves the CPU free to do other work, like play Pico Pong. “I use the PIO to generate a 640×480@60Hz monochrome VGA signal,” says Nick. “Data for the display is stored in a buffer in SRAM, which the PIO program grabs at exactly the right nanosecond, as it paints the screen, via DMA [direct memory access].”

As well as overclocking Pico to 258MHz, nearly double its standard speed, it took a lot of incremental tweaking to get the VGA signals exactly right. “I had to reorganise and rethink the PIO assembly code a number of times to get the data for each pixel on the GPIOs exactly within its 40 nanosecond window.”

Gesture control

The player’s on-screen paddle is gesture-controlled using two infrared (IR) LED / IR phototransistor pairs. “The IR LED shines upward onto a mirror, which reflects the IR light back onto the receiver below,” explains Nick. “When that signal is interrupted (i.e. by a hand), it triggers Pico via GPIO to move the player paddle. One receiver moves the paddle up on the screen, and the other moves the paddle down.”

Why gesture control? “I wanted to do something different from the typical potentiometer controller, so I did some digging through my parts bins to get ideas,” Nick replies. “I first thought I might use a PIR sensor for a similar gesture interface, but even with hardware modifications it wasn’t responsive enough.”

As an alternative, he tried the IR LED/phototransistor pair and responses were smooth and instantaneous. “After playing around with this for a while, I feel like this is the way Pong was meant to be played. If my idea weren’t over 40 years late, I think this could have been the Nintendo Wii of the 1970s.”

Game, set, and match

After showcasing the project on Hackster.io (magpi.cc/picopong), Nick has received plenty of positive feedback from the maker community. “There’s a lot of love for Pong, so I’ve found that many people are drawn to this new way of playing a classic game,” he says. “People see this as something that they could realistically build for themselves, and I think that’s right.  With the coding already done, there is only a simple circuit to build, and the Pico is a very inexpensive development board.”

Nick advises us to keep our eyes open for updates to the projects in the future. Meanwhile, he’s currently experimenting with using his Pico to remotely control a toy helicopter. “I’d like to teach it some new tricks, and control it by voice and/or gestures.

From The MagPi store


Subscribe to the newsletter

Get every issue delivered directly to your inbox and keep up to date with the latest news, offers, events, and more.