Open source 24 (math game) with Raspberry Pi Pico

Jimmy Zhang
3 min readOct 31, 2022

24 is a kids math card game. You grab the non-face cards from a standard deck and randomly choose 4 of them at a time. The first person to use addition/subtraction/multiplication/division to make 24 wins. Extra wrinkle: aces can be used either as 1 or 11. I played it growing up and my kids love it so I made a digital version with the Pico. You press a button and you get a new set of cards.

What You Need

Pico Pico

The main components are the Pico microcontroller and the Display. Pimoroni has lots of details on how to get started with these. If your Pico didn’t come with headers you’ll need to get some and solder them on so you can attach the Display to it. The MVP version of this is just these two components. You can connect it to your computer and use Thonny to run the code.

Stand

I modified a great design by Kevin M. so that it can be printed in two pieces and then (CA) glued together to achieve a better finish. The STL files are in the repo. The stand has four holes sized for M2 bots so that’s a good way to mount or you can just use double-sided tape.

Cordless

If you want to get fancy, you can get a Pico LiPo Shim and a small LiPo battery so that you can not only cut the cord but also get an on/off switch and charge the battery simply by plugging it in. The battery should last for days unless you’re leaving it on all the time.

Usage

The game starts on the title screen. If you press either of the top buttons, A or X, it generates a set of 4 cards — red for diamonds and hearts and black for spades and clubs. You also get a unique pixel art icon per suit. And what appears to be a crown if you squint hard enough on the title screen. Hey, it’s free arts assets. If you like, you can choose different sprites for each suit and the title screen one too. You can even use your own sprites. If you press one of the bottom buttons, B or Y, you go back to the title screen and you get a nice decorative conversation starter.

Worth It?

Guarantee your kids will “git gud” at math real fast.

--

--