Pi-Py-Pi Projects Pi's Digits with Python on a Raspberry Pi 2040 Using an Optical Illusion

This Pi Trifecta calculates the popular constant's digits and displays them uniquely.

James Lewis
1 month agoPython on Hardware

March 14th is known as Pi Day, and it is named after the famous constant. Each year, clever projects emerge to calculate Pi's digits. One example is from Brazil-based developer Cristiano Monteiro. The Pi-Py-Pi calculates Pi's digits on a Raspberry Pi 2040 using Python code.

Several methods exist to calculate Pi's digits. Monteiro used an article by Konstantinos Gavalas that compares Pi algorithms and provides Python examples. Monteiro determined that Bill Gospher's series best fits this application.

Monteiro picked a Raspberry Pi RP2040 microcontroller to do the calculations. One core of the RP2040 does the math, while the other core handles some of the Pi-Py-Pi's visual aspects. For example, as the calculation progresses, the time it takes to calculate the next digit increases. So, Monteiro added a Larson scanner as a keep-alive indicator.

In the 1970s and 1980s, Glen A Larson produced the television shows "Battlestar Galactica" and "Knight Rider." Both shows had a row of lights that chased back and forth. The scanning action named the effect a "Larson Scanner." For example, in Galactica, the (evil, of course) Cyclon robots used the scanner as their eyes.

While a Larson scanner typically scans horizontally, Monteiro's scanner moves vertically. Regardless, anyone will instantly recognize the movement! Ironically, it takes far more Python lines to display the Larson Scanner and digits than the Pi calculation!

A Melopero Cookie RP2040 board is the foundation for the Pi-Py-Pi. It is a circular PCB with large pads around its edge. In addition to the RP2040, the board includes a battery charging circuit and a 5x5 matrix of independently adjustable RGB LEDs, aka NeoPixels. One row of the NeoPixel matrix displays the Larson scanner, and the rest shows the digit calculation, one at a time.

Another interesting aspect is that Monteiro incorporated an illusion called Pepper's Ghost. This illusion comes from a British scientist in the 1800s. John Henry Pepper determined a method to use semi-reflective glass to project an object from one room into another. Monteiro's implementation makes the 5x5 matrix appear to float inside a transparent cube.

After checking out the demo video above, you can download the code and 3D printable case files from this Pi-Py-Py GitHub repo. Monteiro's LinkedIn post describes the overall design in detail.

James Lewis
Electronics enthusiast, Bald Engineer, and freelance content creator. AddOhms on YouTube. KN6FGY.
Latest articles
Sponsored articles
Related articles
Latest articles
Read more
Related articles