Virtual Minecraft birthday cake

By Rob Zwetsloot. Posted

While some (us) might argue that the best part of a birthday cake is the cake itself, there’s definitely something to be said for an interactive model cake that does stuff in Minecraft. Also, there is a real cake underneath it all after you’ve finished with the virtual stuff.

“The virtual cake consists of a looping video of a cake created on Minecraft with nine candles that can be blown out by spinning miniature wind turbines on a matching physical model cake,” Stephen Thompson, the creator of this cake, tells us. “Once all the candles are blown out, the birthday child can lift the model cake to reveal an edible cake which is mercifully free of children’s saliva.”
Sounds a bit more tasty and clean when you put it that way.

“I have always enjoyed making my children’s birthday cakes, with a firm belief that form and function are as important as flavour,” Stephen explains. “In 2021, I was faced with the problem of not being able to blow out candles on the cake… A virtual cake controlled by miniature wind turbines seemed the obvious solution. I’d recently started developing web applications for research and education in surgery, so it made sense to reuse these skills for the virtual cake.”

Virtualising baked goods

While something like this could be in some way achieved in Minecraft Raspberry Pi Edition, that was not why a Raspberry Pi was used.

“Raspberry Pi provided an easy way to interface with the analogue-to-digital converters needed to read the wind turbine voltages,” Stephen says. “Along with sufficient computing power to serve a web application from within the cake itself, using Raspberry Pi enabled me use the same software architecture (Python, Flask, HTML) as I have used professionally. Sourcing the right HAT to measure nine voltages was very easy."

Blowing on the wind turbines generates a small amount of voltage, enough to be detected as a change using an ADC.

The virtual cake instead uses looping video overlaid with candle GIFs served via a web app in a clever way, as Stephen explains:

“The application uses Flask to serve a web page which any device on the local network can access... a JavaScript loop is used to repeatedly send a POST request to the web server asking for the voltage from one of nine analogue-to-digital converters (the ADC board can support up to 16 candles). The code to interface with the ADCs and reply to the POST requests is written in Python and utilises the Flask and gpiozero libraries. All the code is available on GitHub.”

Proof in the dessert

Despite the best efforts of developers, sometimes an interface is not always clear to the user – especially when they’ve just turned nine.

The guests quickly figured out what they had to do to blow out the candles

“I was slightly nervous that the children would find it too abstract, but they worked it out pretty quickly,” Stephen mentions. “They saw the connection between the plastic wind turbines on the cake and the candles on the screen, and worked out that you could turn the on-screen candles off by blowing on the wind turbines. There was much laughter and smiles.

The children were also very pleased to discover that there was actual cake underneath it all.” If only there were cake underneath every interactive Raspberry Pi project.

There is space under the model cake for the electronics and the real cake

From The MagPi store

Subscribe

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.