Virtually "Stream" the Digits of Pi From a Spigot

Created for Pi Day, this spigot uses a Raspberry Pi to slowly "drip" the digits of 𝜋 onto an LED matrix.

gatoninja236
almost 5 years ago Lights / Art

The Design

Pi Day is a global celebration of our favorite (maybe second favorite for those tau lovers) irrational number, pi. So for this year's Pi Day, Instructables user bornach made a fun way to display an approximation by slowly "dripping" digits from a spigot onto an LED matrix below.

Components Used

The computer that makes all of this possible is a Raspberry Pi, which was chosen because of its relatively powerful CPU, abundance of RAM and connectivity, and the name. The digits are shown on a series of five daisy-chained MAX7219 8x8 LED modules, which greatly reduces the number of pins needed.

The spigot itself is constructed from three red LEDs, a 10K potentiometer, and a few resistors to reduce the current consumed by the LEDs and pull up the lines on the potentiometer.

Construction

After getting these components together, the project's creator began by chaining the five LED matrices and reinforcing them with a few popsicle sticks so they didn't fall apart under their own weight. They were then connected to the Raspberry Pi's hardware SPI pins, which lets data get pushed faster than software-defined SPI. The three LEDs represent water slowly dripping from a faucet, and they came from a string of Christmas lights, thus making the assembly process much easier.

The spigot assembly was then wrapped in cardstock that had been painted with a metallic finish for a brass look. Finally, the potentiometer was mounted in the top and given a small handle. With the Raspberry Pi in a clear case, the spigot was placed on top, along with the LED matrices.

Generating the Digits

Perhaps the most calculated constant, enthusiasts of pi love seeing just how far they can go when generating its unending digits. For this project, many of the algorithms that would normally be used cannot due to either their recursive nature or dependence on previous digits to get the next. This is where the PiDigits python package comes in handy, since it can return an array of digits of an arbitrary length. It's based on the 'Unbounded Spigot Algorithm for the Digits of Pi' by Jeremy Gibbons, which uses these steps to generate an approximation:

To read more about the math behind it, you can view his paper here.

Displaying Pi

Armed with an array of digits, it was time to start printing them out. The program begins by initializing the display, drip LEDs, and potentiometer with the correct pins, as well as the digit generator instance from the pidigits package. Every few seconds a new digit appears to emerge from the faucet by lighting the LEDs in order and then using a "grow" effect to make it appear like the digits have been splashed onto the surface. Everything on the display is also continuously shifted to the end to make room for the new digits.

Other Interesting Features

You might have been wondering what the purpose is for the potentiometer, and the answer is that it can stop the "flow" of digits with a quarter-turn of the handle, just like an actual faucet.

Since the Raspberry Pi lacks an analog-to-digital converter, the Pi checks if the handle is in the "on" position by timing how long it takes for a single 0.47uF capacitor to reach a certain threshold. The Spigot also has the ability to drip text, which might come in handy for future projects.


gatoninja236

Embedded Software Engineer II @ Amazon's Project Kuiper. Contact me for product reviews or custom project requests.

Latest Articles