The Adafruit PyGamer is a powerful platform for creating your own handheld games. It can be programmed in MakeCode, CircuitPython, and Arduino C++. However most of the games that have been developed for this platform have been single player games. In this guide, learn how you can attach two RF69HCW FeatherWings to the back of two PyGamer devices and use RF radio communication to construct two player games.

It's all made possible by the TwoPlayerGame Library written in C++ using the Arduino IDE. The library provides you with base object classes that you can extend with your own custom classes that define the rules of your game. The base classes form a game engine that handles negotiation of the start of the game between the two devices, the back-and-forth transmission of moves and responses, and other housekeeping duties. This lets you focus all of your efforts on creating the game itself.

This includes some sample demonstration games "Tic-Tac-Toe" and "Battleship" that you can use as models for creating your own two player games.

The object oriented modular design of the game engine will also allow us to develop other types of two-way communication such as Bluetooth, infrared or other RF systems without needing to modify your game at all. You can simply drop in a different communication module and recompile. These other communication systems are still a work in progress, but the RF69HCW FeatherWing is fully supported now.

The sample programs provided here also run on the PyBadge which is not quite as feature-rich as the PyGamer. Notes are provided of any differences throughout the tutorial. It will not work with the PyBadge LC, a low-cost version, because it does not have a socket on the back to plug in an RF board.

The system should also be compatible with the Adafruit Clue board but will require implementation of a different communication method, using Bluetooth instead of the RFM69HCW 'Wings. 

Hardware Required

To implement this project, you will need 2 PyGamer M4 Express units and 2 RFM69HCW Radio FeatherWings. 

Angled shot of Adafruit PyGamer for MakeCode Arcade, CircuitPython or Arduino.
What fits in your pocket, is fully Open Source, and can run CircuitPython, MakeCode Arcade or Arduino games you write yourself? That's right, it's the Adafruit...
Out of Stock
Angled shot of a Adafruit Radio FeatherWing - RFM69HCW 900MHz - RadioFruit.
Add short-hop wireless to your Feather with these RadioFruit Featherwings. These add-ons for any Feather board will let you integrate packetized radio (with the RFM69 radio) or LoRa...
In Stock

Note American users should order the 900 MHz model and European users should use the 433 MHz model.

Angled shot of LoRa radio board.
Add short-hop wireless to your Feather with these RadioFruit Featherwings. These add-ons for any Feather board will let you integrate packetized radio (with the RFM69 radio) or LoRa...
In Stock

If you are going to use sound effects, you will also want to add a speaker or use headphones in the provided stereo headphone jack. Caps for your buttons and an acrylic case are nice additions as well. You will also want a Lipo battery for portable use. Or get the whole bundle in the PyGamer Starter Kit.

Adafruit PyGamer Starter Kit with PCB, enclosure, buttons, and storage bag
Please note: you may get a royal blue or purple case with your starter kit (they're both lovely colors)What fits in your pocket, is fully Open...
Out of Stock
Adafruit PyGamer Acrylic Enclosure Kit
You've got your PyGamer, and you're ready to start jammin' on your favorite arcade games. You gaze adoringly at the charming silkscreen designed by Ada-friend...
In Stock
Mini Oval Speaker with Short Wires
Hear the good news! This wee speaker is a great addition to any audio project where you need 8 ohm impedance and 1W or less of power. We particularly like...
In Stock
Angled shot of 10 plastic button caps colored reddish-orange, yellow, white, and black.
These Reese's Piece's lookin' bits fit perfectly on top of tactile buttons with 2.4mm square tops and give a satisfying 8mm diameter surface area for your fingers to...
In Stock
Lithium Ion Polymer Battery 3.7v 350mAh with JST 2-PH connector and short cable
Lithium-ion polymer (also known as 'lipo' or 'lipoly') batteries are thin, light, and powerful. The output ranges from 4.2V when completely charged to 3.7V. This...
Out of Stock

As mentioned earlier, the system will also work with the PyBadge as an alternative to the PyGamer but not with the PyBadge LC. NOTE that the PyBadge does not have a headphone jack, so if you want to use sound effects you will need a speaker.

Angled shot of a Adafruit PyBadge for MakeCode Arcade, CircuitPython, or Arduino.
What's the size of a credit card and can run CircuitPython, MakeCode Arcade or Arduino? That's right, its the Adafruit PyBadge! We wanted to see how much we...
Out of Stock
Adafruit PyBadge Starter Kit with PCB, lanyard, battery and cable
What's the size of a credit card and can run CircuitPython, MakeCode Arcade or Arduino? That's right, it's the Adafruit PyBadge! We wanted to see...
Out of Stock

Skills Required

This is a relatively simple project if all you want to do is play the games that are provided. This tutorial may be updated if new games are added to the GitHub repository. You will have to solder a set of header pins on the RFM69HCW and solder an antenna and some jumper wires. There are a couple of flags you will need to edit in the code before uploading. However no programming skill is necessary.

If you want to develop your own games using the TwoPlayerGame Library, then it will take a reasonable amount of knowledge of object oriented programming techniques in C++. The detailed descriptions of the object classes and methods might serve as a lesson in object oriented programming techniques for a programming student.

This guide was first published on Jul 07, 2020. It was last updated on Mar 08, 2024.

This page (Overview) was last updated on Mar 08, 2024.

Text editor powered by tinymce.