Introduction: Pi Clock

Here I present to you physical evidence that 100,000 digits of Pi is actually a useful number, contrary to what NASA might think about the topic! (Skip to Step 12 near the end of this Instructable to read some points of view.)

I built a clock from digits of Pi. I think you will enjoy this.

I discovered that every minute of the day can be found as a 4-digit number within the first 100,000 digits of Pi. So why not build a clock out of it! So I did.

About the Clock

I created a pure javascript webpage that shows the current time of day.

  • All 100,000 digits can be found on the page. You can scroll up or down to see them all.
  • Every minute, the clock will scroll to the relevant region where the current time is found.
  • The hours and minutes are highlighted large and in standout colors
  • Seconds tick by as two-digit numbers nearby that briefly change color so you can spot the number.

The webpage can run on any browser but I implemented it on a Raspberry Pi. (Of course!) You can run it on any normal computer. So if you are curious, you can go to this GitHub link, download the code and open the file index.html in your browser. https://github.com/mhirst1960/pi-clock.

To make it even easier for you, I created a simple website for fun. The code on the website is exactly the same code I will describe below. Choose one of these links depending on your style:

If you like this clock, make sure to check out my Rubik's Clock Instructable. You will probably like that one too!

About the Pie Delivery System

Great add-on feature: this clock delivers pie. Every day at exactly 3:14:15.9, a piece of pie arrives on the pie plate! The trip starts at 3:14:15 when a gate opens at the top of the clock releasing a piece of pie (3d printed PLA maybe isn't the best flavor but it is the most fun!). The PLA pie takes a ride down the slide and lands in the pie plate at just about .9 seconds later.

Pi Time!

Every day.

Regarding the Fusion 360 plastics design: probably the most interesting step is the step that describes the slide construction. The spline tool is a very cool thing, especially when done in a 3D sketch. If you've used Fusion 360 before this step might be enlightening to you. It was for me. If nothing else, maybe skip to Step 9: "Pie Delivery Slide - Fusion 360".

Supplies

Parts for the Computer and Display

  • Raspberry Pi 5 adafruit
  • Power Supply for Raspberry Pi 5 adafruit
  • RTC Battery adafruit
  • IMPORTANT: purchase your battery at the same time as the Raspberry Pi 5. In the USA there are restrictions on shipping Lithium Ion batteries alone in a box. Your country may have similar restrictions.
  • SunFounder TS7-pro 7 Inch Touchscreen for Pi 5 amazon.com
  • 90 degree Down USB-A amazon.com (optional: for occasional need to attach a keyboard)
  • USB-C 180 degree adapter amazon.com


  • 2 - M2x16 screws
  • 4 - M2x6 screws

Parts for Optional Pi-time Delivery System

  • 3v Relay Board for Raspberry Pi Amazon
  • Note: probably this relay is way overkill, it just happened that I had some of these lying around from a previous project. There are much smaller choices available that should work fine too.
  • Send me a comment if you use a different relay. Let me know if it worked and if the mounting holes are good for you. If it works, maybe I can update the mounting plate to accommodate.
  • Update: I found a smaller relay from Sunfounder sold on Amazon that seems to work great. Unfortunately it doesn't fit in the screw holes of my current design. Stay tuned: I should be able to update the 3D design to accomodate.
  • DC 12V Micro Push Pull Solenoid Electromagnet Mini Solenoid Amazon
  • 9 volt battery
  • 9V I Type Battery Snap Connector Amazon
  • 20cm Dupont Wire Male to Female Breadboard Jumper Wires Amazon
  • 4x M2x4 screws
  • 4x M2x6 screws

Parts for Pie-release button

Step 1: Why I Picked These Parts

About the Raspberry Pi 5 and RTC

  • This project should run fine on any Raspberry pi 3, 4 or 5 but I recommend the Raspberry Pi 5.
  • One "must have" requirement for any clock is that it should keep time regardless of if it is connected to the internet. A Real Time Clock (RTC) component paired with a battery does this for you.
  • The Raspberry Pi 5 has RTC built in. Enabling it is as simple as connecting a battery. That's it!
  • On the Pi 3 and 4, you will need to wire a RTC circuit and configure it manually. I documented how to do that in my Rubik's Clock Instructable.

About the Touchscreen

  • If you pick a different touch screen beware that many of the 7" screens have problems running on the new Raspberry Pi 5. Several I tried failed touch functionality on the touch screen. (Possibly by the time you build your pi-clock, companies will fix their bugs.) You may have better luck with the Raspberry Pi 3 or 4 with the cheaper 7" screens.
  • If you select a cheaper touchscreen you may also need to buy a bunch of 90-degree and 180-degree adapters and other stuff like short cables or ribbon to insure the wires are hidden behind the case.
  • Another nice thing about this Sunfounder Display is that it comes with a 100% compatible Raspberry Pi connector soldered to the back. The Raspberry Pi itself mounts to the back of the display into a female connector for a nice solid connection.
  • Many displays that are available use a similar mounting technique but do not expose the valuable pins on a seperate header connector. You can work around this issue using wire wrap to connect things. That works but it's cumbersome.

About the Relay

  • I'm happy with the relay I used but it is quite big for a project like this. I only used this one because I happened to have some lying around from previous projects.
  • If I were starting fresh I probably would have selected a smaller relay.
  • Please let me know your experience if you pick a different relay. Probably any 3 volt or 5 volt (input) relay will work.
  • Someday I might update this Instructable with a different relay if I find one I like better.

About the Solenoid

The solenoid I picked is perfect for this project.

  • It is tiny
  • It is not very strong. But it only needs to move a very light piece of PLA.
  • It uses very little electricity and only triggers once or twice a day so the 9V battery will probably last years.

About the Battery

Generally speaking 9v Alkaline batteries are a bad choice for many electronic projects. The design is not very efficient with electricity.

Mainly I had a bunch of these lying around (rejected from previous projects) and I had a bunch of neglected connectors. So I'm just using up old parts.

But regardless of my personal situation, it is a great choice for this project:

  • One battery supplies enough voltage to reliably trigger the relay.
  • It is used only about once or twice a day. I'm sure it will last years.

Step 2: Assemble Raspberry Pi to Screen

Assemble Raspberry Pi to Touchscreen

  1. Insert the Real Time Clock battery into the connector next labelled "Bat". This connector is between the USB-C power and HDMI on the Raspberry Pi board. (If you forgot to buy a battery: go do that now. You won't be disappointed after you have that.)
  2. Mount the Raspberry Pi onto the back of the 7" touch screen into the matching connector.
  3. insert the supplied 180-degree USB-B to micro-USB adapter into the matching connectors.
  4. Insert the supplied 180-degree HDMI adapter into the matching connectors.
  5. Insert the separately-purchased 180-degree USB-C into the power connector on the Raspberry Pi. (Optional but recommended since it keeps the wires hidden.)
  6. Connect the power supply to the USB-C.
  7. Power it on.
  8. The Raspberry Pi should be fully functional. Make sure to verify that you can use your fingers to access menus and other functionality.
  9. Connect a mouse and keyboard for initial setup but you can disconnect these after you pi-clock is fully configured and running.

Attach the Case

  1. Print out all the parts on a 3D printer. The STL files are attached.
  2. Lay down the touchscreen into the back of the case so all the holes align.
  3. Push together the two halves of the shield.
  4. lay down the shield (sides) on top of the front plate. The shield tabs need to be sandwiched between the touch screen and the front plate.
  5. Gently screw in the top two M2x6 screws so the touchscreen and shield are attached at the top.
  6. Insert the M2x12 screws into the holes in the foot as shown in the photos.
  7. Thread them in so they poke out the other side slightly.
  8. The inner holes are for the SunFounder display.
  9. The outer holes might work for you if you have a different display or can be ignored.
  10. Lay the foot on top if the assembly and continue to tighten the foot into place.
  11. Make sure the shield tabs are sandwiched between the screen and the face plate.
  12. Do not over-tighten the screws. A slightly firm grip should be fine to hold everything in place.
  13. Slide the trophy topper into place.
  14. Optionally you may attach the trophy with the remaining M2x6 screws.
  15. I printed a selection of trophies in different colors. I decided not to attach mine with screws. This way they are easy to swap out when my mood changes.


Step 3: 3D Printing

I've attached all the 3D print parts you will need for this project. Or you can download everything from Thingiverse.

I printed everything using a selection of Hatchbox PLA sparkle colors:

  • Sparkle Red
  • Sparkle Green
  • Sparkle Yellow

You definitely need to use support for most parts. Cura Ultimaker has a "tree support" feature. I recommend that.

All of the parts are my own design except the "yummy" pie. The 60 degree slice that gets a daily ride down the slide, is something I found on Thingiverse. It's perfect! Why mess with perfection!

The "save as mesh" feature of Fusion 360, doesn't seem to have controls for rotating objects to the direction I would like for printing. (Maybe I just haven't found the trick yet. If you know the trick, please add a comment below: I'd love to know how to do that.)

I used the Cura Ultimaker to rotate the parts how I like, then exported them. Hopefully this will make it easier for you.

Gate Version 2

On April 29, 2024 I posted a new version of pi-gate on April 29, 2024. It's a little shorter and has fins to add some angle. If you downloaded the older version this might work a little better for you.

Step 4: Install on Your Raspberry Pi

Install a Fresh Raspberry Pi

Although you don't necessarily need to start fresh with a new clean SD Card, I recommend it.

  • You will get the latest updates.
  • If you use your Raspberry Pi for other things, maybe you don't want to install over the top of that. This installation puts the Raspberry Pi in "kiosk" mode. That makes it difficult to access the normal menus that become hidden. (Note: you can always hit CTRL-F4 to exit kiosk and reach the menus. If you have a keyboard attached.)
  • Note: if you previously made my rubik's clock, you will want to uninstall that before installing this clock to avoid conflicts. (After all it does not make sense to run two clocks at the exact same time on the same kiosk.) Simply run uninstall.sh in the rubiks-clock area before running install.sh as described below.

So, if you have a good Raspberry Pi that you use all the time, consider pulling out the SD Card and set it aside. Replace it with a fresh new one. You will need an SD Card that is 8GB or larger.

  1. Download the Raspberry Pi Imager App from raspberrypi.com
  2. Choose Device: Raspberry Pi 5
  3. Choose OS: Raspberry Pi OS (64 bit)
  4. Choose Storage (your SDCard that you have inserted into your computer). Maybe it will show "Generic Mass-Storage Media - 15.9 GB" or something like that.
  5. Hit "Next"

To make things easier later, consider selecting some options now by pressing "Edit Settings":

  1. General tab
  2. Host name: pi-clock
  3. Username: pi
  4. Password:
  5. SSID: <your WiFi network name"
  6. Password: <your WiFi password>
  7. Set Local settings
  8. Time Zone: Pick your region
  9. Keyboard layout: <your preference>
  10. Services tab
  11. I recommend enabling SSH. It will make installation easier.
  12. Most people pick "Use password authentication"
  13. But "public-key authentication" might be your preference.
  14. Your choice
  15. Hit "save"
  16. A warning message will ask you if you are sure: All existing data on 'Generic Mass-Storage Media' will be erased. Are you sure you want to continue?"
  17. Hit "YES" and the SD Card will be overwritten with code that runs the Raspberry Pi.

Power on Your Raspberry Pi

Once the SD Card is complete, push it into your Raspberry Pi. Plug it the Raspberry Pi to a wall socket, and follow the instructions.

Enable VNC

It might make installation a little easier if you enable VNC. VNC is optional but if you do, you will be able to access the Raspberry Pi remotely from your laptop.

Install the Pi Clock

I posted the javascript code here: https://github.com/mhirst1960/pi-clock. There are instructions in the README.md. I will repeat some of that here.

You can open a shell on the Raspberry Pi or (my preference) from your laptop run one of these commands to log into your raspberry pi. Your suffix might be different but try one of these:

ssh pi@pi-clock.local
ssh pi@pi-clock

Now that you are logged into your clock, run these commands:

cd /home/pi/
git clone https://github.com/mhirst1960/pi-clock.git
cd pi-clock/raspberrypi-init

Get Help

The command to install is this: ./install.sh

The option --help shows you a cheat-sheet of possibilities. Here are all the options:

./install.sh --help

Usage: ./install.sh [--style 12|24] [--no-http] [--no-splash] [--no-wallpaper] [--keep-trash] [--keep-mounts]

All arguments are optional here is a summary:
 -h, --help      show this help message
 --style       12 = 12-hour clock, 24 = 24-hour clock
 --no-screensaver   do not automatically show Pi clock full screen
 --no-httpserver   do not install http server
 --no-splash     do not install custom boot splash screen
 --no-wallpaper    do not install Pi wallpaper
 --no-fonts      do not install ocr-a font
 --keep-trash     do not hide the trashcan icon
 --keep-mounts    do not hide sdcard mount icons
 --no-autohide-cursor do not automatically hide the mouse cursor on timeout
 --no-extras     do not modify: splash screen, wallpaper, desktop icons


Defaults


By default the script will update your Raspberry Pi with a new picture (Pi) when it boots, and a new backdrop (a different picture of Pi). It will set things up so the clock is displayed in full screen kiosk mode.

Note: to exit the clock from kiosk mode, connect a keyboard and type "CTRL-F4". That means hold down the Control key while pressing the F4 key. You will then have full access to the desktop.

By default the clock shows time based on the local you configured. For me this 12-hour format (am/pm). If you want 24-hour format use the option "--style 24". If you want 12-hour format use "--style 12" if that is not already your default.

By default it starts an HTTP server (aka a website in your home). If you don't want this, just add "--no-httpserver" to your list of arguments.

So if you run it with no arguments you get this:

./install.sh

install http server    = y
auto-start browser     = y
clock style        = 12
Pi splash screen on boot  = y
Pi desktop         = y
Additional Fonts      = y
hide trashcan icon     = y
hide sdcard mounts icons  = y
autohide mouse cursor   = y

Timezone=America/New_York
Current time: 11:54:21 PM

Is configuration good? [Y or N] n  


Maybe you don't want that. Just answer with 'n' (aka no) and the script will exit without doing anything.

Maybe you want to show 24-hour time. So run it like this:

./install.sh --style 24

install http server    = y
auto-start browser     = y
clock style        = 24
Pi splash screen on boot  = y
Pi desktop         = y
Additional Fonts      = y
hide trashcan icon     = y
hide sdcard mounts icons  = y
autohide mouse cursor   = y

Timezone=America/New_York
Current time: 23:54

Or maybe you also don't want to start the HTTP server:

/install.sh --style 24 --no-httpserver

install http server    = n
auto-start browser     = y
clock style        = 24
Pi splash screen on boot  = y
Pi desktop         = y
Additional Fonts      = y
hide trashcan icon     = y
hide sdcard mounts icons  = y
autohide mouse cursor   = y

Timezone=America/New_York
Current time: 23:57

When you are happy about the setup, type "y"

After installation completes, reboot the Raspberry Pi

reboot

When it finishes booting, it will be a clock. Done! Enjoy your new clock!

You can scroll up and down through all 100,000 digits of Pi. If you scroll all the way to the top, you can see the all-familiar 3.1415 that starts the forever sequence of digits of Pi. Or scroll all the way to the end to see the one hundred thousandth digit! (As web pages go, that 100,000th digit is surprisingly not all that far away.) I could have presented a million digits but I did not need to. All the minutes of the day can be found in the first 100,000 digits. If you need 1 million digits, it's easily available. It's posted various places including where I got my 100,000 digits: angio.net


Step 5: Verify RTC Time (No WiFi)

If the Real Time Clock (RTC) is not working correctly, time will be incorrect when there is no internet. Time will be bad if there is no WiFi! So now is a good time to test it.

Time is important

Time on a clock is most important. You should do everything possible to make sure your clock time is always correct.

There will come a day when you will not be connected to the internet. Someday you might want to bring your pi-clock to a friends house or to work. (Think: Pi-Day party next March 14th!)

  • You might not know the WiFi password where you are going.
  • More likely: you might not want to bother to fiddle with passwords where you are going. It is, after all, this is bit cumbersome when in kiosk mode. (See below.)
  • Maybe your work enforces restrictions on WiFi access.

If you are using a Raspberry Pi 5 and the RTC battery is connected, the clock should automatically keep time when power is removed. But you should test it anyway. If you forgot to buy a RTC Lithium battery (or forgot to connect it!) you might someday have problems with time-of-day. It would be better to know about that now.

Bring your clock somewhere

A surefire way to find out if your time is good would be to take you clock somewhere else. Plug it in where there is no WiFi. If time is good, then you are all set.

Temporarily Disable WiFi

Or you can test the RTC by temporarily disabling Wifi.

Here are the steps:

  1. Connect a keyboard (and optionally a mouse). If you did not install a 90-degree or 180-degree USB adaptor you will have a hard time inserting the keyboard USB. Luckily the case is designed flexible enough to easily overcome this situation.
  2. Remove the top two screws at the back of the case.
  3. Gently split open a gap along the top.
  4. Push the keyboard's USB into an available connector.
  5. Hit the key combination [CTRL]+F4 to stop the clock from running.
  6. The standard Raspberry Pi console will appear.
  7. Find the wifi symbol in the upper-right corner of the display. It looks like a beacon -- or set of concentric arcs -- when it is enabled. (Or red X/X when not.)
  8. Press it with your finger or a stylus if you have one (or mouse if you attached one).
  9. Press the menu option "Turn Off Wireless LAN"
  10. The WiFi icon will change to red X/X.

Now unplug your pi-clock.

Leave it unplugged for 5 or 10 minutes or more...

Plug in back in

  1. Plug the clock back into the wall socket.
  2. It should boot into kiosk mode and show the time. Is time correct?
  3. If time is not correct, probably something is wrong with the RTC.
  4. Maybe the battery is not connected?
  5. Post a comment: I can help you troubleshoot.

Make sure to re-enable WiFi!

  1. If the time is correct make sure to re-enable Wifi. It's pretty much the same steps as above:
  2. Press [CTRL]-F4
  3. Press the WiFi icon (red X/X because it is disabled)
  4. Select the menu option "Turn On Wireless LAN"
  5. The icon will switch to a beacon symbol.
  6. Unplug the Raspberry Pi
  7. Plug it back in.
  8. Enjoy the confidence of correct time!

Step 6: Daily Pie Delivery at Pi-time!

I've built a gadget add-on that delivers pie at 3:14:15.9. It works great so I'll add some instructions.


Summary of pie delivery

  • cron job runs at 3:14:00
  • sleep 15 seconds
  • Pie takes about 0.9 seconds to reach the bottom of the slide
  • Delivery is complete at 3:14:15.9
  • (I kind of made up the number 0.9 seconds. Sometimes it's true. Sometimes not. But it makes a great story!)
  • I'd say that's a nice round number!
  • GPIO triggers a relay
  • relay connects a 9 volt battery to a solenoid
  • Solenoid opens gate
  • Pie slides down the chute to the pie plate.

Pi Day Requires Extra Pie

And on March 14th at 1:59 pm an extra pie is delivered. I can't wait!

Decoration

I decorated the pie plate with the sequence of digits found at 99,948 through 100,000. Obviously Pi continues on from there but that's where my project ends.

Take a look at Step 9 where I describe how I designed the slide in Fusion 360.

Step 7: Colors

Every hour the colors change to a new theme. I found many great choices at Adobe and selected four.

  • Architecture
  • Gnome
  • Pi Day
  • Botanico

If you want a bigger selection or a different selection I'm sure you will find something you like at Adobe's color site.

Just edit colors.js and add more entries in the arrays themes[] and themeColors[]

Step 8: Fusion 360 Case Design

I created a fairly simple case (or frame) using Fusion 360. The front is decorated with the first 72 digits of Pi. There are screw holes to attach the display onto the front. The legs attach through the same set of holes.

I have attached the Fusion 360 file if you need to make modifications.

  • Maybe you have a different display where the screw mount holes don't line up to my build.
  • Maybe you want to repurpose the case with different text around the perimeter.
  • Or maybe you have a cool idea for your own Trophy Topper.

I've also attached the 3d-print STL files for you to print on your 3d-printer.

Model the 7" display

We will first model the SunFounder 7" display and the mounted Raspberry Pi 5. No need to get fancy. This entire component is simply to help visualize clearance requirements.

  1. Create a sketch using documented dimensions as well as dimensions measured with calipers (because there were errors in the official documentation).
  2. Extrude the motherboard 2mm as a new component
  3. Extrude the display another 8mm
  4. Make sure mounting holes are accurately placed.
  5. Create a sketch for key components and extrude them (join)
  6. Create a simple sketch the size and placement of the raspberry pi 5. And extrude (join) it the full amount of space it occupies.
  7. Round off the mount corners with fillet

Decorate with a Decal

  1. Insert a screenshot as a decal onto the face of the display. It looks nicer and helps later when you want to find the front and the top when orienting other components.

Front Cover

Now we will create a frame that the display can mount to. The frame should hide most of the dark space around the viewable area of the display. It should also hide all the cables and connectors. And I thought it would be fun to decorate the front with digits of Pi.

  1. Create a new sketch
  2. Make a rectangle 130x205mm. This defines the overall size ot the front of the display. I made it just small enough to fit onto the build plate of my Ender 3 so I could print it lying flat.
  3. Make sure the above rectangle is centered.
  4. Project various items from the first (display) sketch:
  5. rectangle of the display
  6. rectangle of the viewing area. (The image from the Raspberry Pi is actually a bit smaller than the corners of the actual display.
  7. The locations of the four mounting holes. (Actually 8 mounting holes: I added some extra holes that align to some other common 7" displays -- I hope this works for you.)
  8. Create a rectangle 1mm larger on each side compared to the projected screen dimensions. This will be the well that the display sits inside. With clearance.
  9. Create a new component. This will be the front cover.
  10. Extrude an 8mm thick frame.
  11. Next extrude (join) another frame 2mm on top of (in front of) the previous. The square center is smaller and hides the blank borders that surround the image when the display is powered on.
  12. Extrude (cut) the mounting holes.
  13. Create a new sketch for the Digits of Pi
  14. generate a path around the perimeter. I Used a "Control Point Spline" for my path.
  15. Pick a starting point on the upper-left and draw a couple of lines over toward the upper-right corner.
  16. Click beyond the upper-right corner to make an arc into the onto the right side.
  17. Continue doing this all the way around the face of the frame.
  18. Fiddle with control points until you like the curve that circles all the way around the frame.
  19. I chose to make a slightly wavy "funky" path.
  20. Now create text along the path
  21. Select the path
  22. Copy/paste however many digits of Pi you like. After some experimentan I decided 72 digits fit well along the curve. Not too crowded. (Technically I should say "74 characters" since "3." is another two characters in the string. But who's counting anyway!)
  23. Extrude (join) the numbers onto the front of the frame to a height of 2 mm.
  24. You will probably want to go back and edit your path now. Move the control points around until you are happy with the layout of your text. It took me many iterations before I was content.

Sides

The sides (and top) form a 2mm thick "fender" or "shield" that hides the electronics that are mounted on the back of the display. There is a clasp at the top to hold the left and right sides together. I did this in two pieces in order to better fit on my 3D printer build plate.

  1. Create a sketch of a couple of concentric rectangles for a 2mm border around the perimeter of the face frame.
  2. Extrude this thin section 30mm as a new component.
  3. Add some tabs that reach inward to overlap the faceplate mounting holes
  4. Cut holes in these tabs for screws to pass through
  5. Use the splitting tool to cut it in half.
  6. Now you have a left and a right section.
  7. Now make a connection between the two pieces:
  8. On one half make a tongue that sticks out 12mm
  9. On the other half make a slot to receive the tongue.
  10. Round the corners of the shield to match the rounded corners of the face plate.

The Foot (or legs)

The foot keeps the clock upright with a 30 degree lean angle. I made it rather beefy so-as to help lower the center of gravity of the display.

I created legs as a separate component. It will be screwed into the back of the clock through the two mounting holes at the bottom.

  1. Create a new sketch
  2. This will be a long thin rectangle along the bottom of the display.
  3. Constrain the bottom edge to align with the bottom edge of the display.
  4. Create a new component by extruding only 1mm. Yes: very thin!

Now we are going to apply a 30 degree angle to the 1mm thin slice that initiates our component

  1. Create a 30 degree draft such that the bottom sticks out and the top edge remains 1mm away from the back of the display frame. If you prefer your display to sit at a different angle than 30 degrees, you can adjust the draft angle as you like it.
  2. The new angled surface will be used for a new sketch.

Extend the legs out at a 30 degree angle

  1. Create a simple sketch. It is just a rectangle that covers the most recent surface we created.
  2. Extrude (join) the leg far enough so the display will not fall over when you push lightly. 50mm seems good to me but maybe you will want to make yours longer for better stability.
  3. Using chamfer, I tapered the legs to be thin where they end.

Paying attention to required clearance, dig out a slot to avoid interference with the (modelled) Raspberry Pi.

Make holes that align with the mounting holes on the touch screen. I created a couple of extra holes so the legs can be compatible with different choices of touchscreen -- maybe you don't want to use the SunFounder 7" display so I hope it is good.

  1. New sketch on the face that matches to the front face.
  2. Project the mounting holes from a previous sketch
  3. Create 3mm and 5mm circles centered on the above projected points
  4. Cut 3mm holes all the way through the leg
  5. Cut 5mm holes partly through. During assembly, the head of your mounting screws needs to be recessed into these holes.

Cut an arc from the legs. It looks nicer (and saves material).

  1. Create a sketch on the bottom of the legs
  2. Make a 3-point arc along the back of the leg.
  3. Extrude (cut) out the section defined by the arc.

Now we need to add a bit of vertical support the the leg.

  1. Create a sketch on top of the leg
  2. make a couple of rectangles aligned with the front edge and side edges of the foot
  3. Extrude (join) up far enough to provide a good surface for the display to lean on. I chose 45mm.
  4. Note: make sure your mounting holes created previously pass all the way through the part. I didn't plan ahead so I had to cut my holes again. Not a big deal.

Clean it up

  1. Add fillet all around so there are no sharp edges.

Trophy Topper

I topped the case with a big bold Pi symbol. I call it a trophy! Times Roman font has a nice looking Pi symbol so I picked that for my theme. On a Mac the key combination Option+p generates a Pi character. (The Windows PC should have a command to generate this special character. Maybe someone will add a comment for what that is!) This trophy also acts as a clamp to hold the left and right shields solidly in place (and to hide the seam).

  1. Create a sketch of a rectangle in the X-Y plane of the top of the case. 52mm wide is a good size. This rectangle extends an extra 3mm beyond the back of the case giving room for future extrudes that wrap around the fender top so it will clamp snuggly in place.
  2. Extrude this platform as a new component.
  3. Extrude a couple more times to wrap around the fender to form a clasp.

Now you have a platform that is parallel to the top of the of the case. But note that the whole case leans backward at a 30 degree angle. I wanted my trophy to stand up straighter: less than 30 degrees but not quite vertical.

  1. Construct a plane at an angle. Select the front edge of the platform we created. A (negative) 70 degree setting results in a proud 10 degree backward lean.
  2. extrude a good tall cube above the platform. It doesn't matter how big the cube is, but make sure it extends tall. Soon we will throw away all of the top.
  3. Now use the "Split Body" tool to split our platform along the offset plane.
  4. So we will just throw away the top: Select the upper of the two bodies and use the "Remove" tool to make it disappear.
  5. I sliced away the back corner of our platform. It looks better. The steps are similar as as above.

Now we officially have a platform to set our trophy on.

Time to Build the Trophy!

  1. Create a sketch on the top surface of the platform. This one is simple: 10mm thick rectangle that extends the entire width of the platform.
  2. Extrude up 25 mm or any amount you want. It doesn't matter how tall. It is temporary we will soon throw the whole thing away.
  3. Create a new vertical sketch on this new surface.
  4. Use the "Text" tool to create a giant Pi symbol (π). On a Mac computer type Option+p. I made it 30mm tall and centered.
  5. Use Times-Roman font. It's a nice looking Pi and matches the big π in the software on the active clock.
  6. Center it using a center line and symmetry constraints.
  7. Make sure the bottom of the Pi sinks a bit below the platform that it will sit on.

Now that we have the sketch we like, throw away the block wall we created. Like I said: it was temporary.

  1. Extrude (cut) the whole wall leaving only the platform (and a nice sketch)

Trophy time!

  1. Extrude (join) the Pi symbol 10mm.
  2. Center it front-to-back using 5mm offset.
  3. Clean it up with 0.5mm fillet all around. (all 55 edges!)

Sit back and admire the creation!

Step 9: Pie Delivery Slide - Fusion 360

Here are the Fusion 360 steps I used to form the launcher and slide around the back of the clock.

Splines

Regarding Fusion 360, possibly the most interesting part of this whole design is the usage of a 3D spline to make the slide. If nothing else, skip down the section "Creating the Slide". It's interesting.

Model the Solenoid

It is important to precisely model the solenoid. You don't need to get fancy. Just capture the "box" housing accurately. And capture the armature or "piston" accurately.

The Gate

The gate is a simple design. Just make an upside down square "U" with a hole that aligns tightly with the round armature.

  1. create a sketch vertically at the back side of the solenoid
  2. A couple of rectangle form an upside down "U" and you are done.
  3. extrude out across the top of the solenoid.
  4. Make sure to extrude less than the full depth of the solenoid housing. This solenoid is not very powerful so any friction on the sides will cause failure to open.
  5. I used .5mm offset on both sides.
  6. Create a simple sketch at teh underneath the arch top.
  7. project the circle from the armature.
  8. Create a new circle 0.1mm larger for a tight fit over the top of the plunger.
  9. Extrude (cut) a hole in the bottom of the arch for the rod to jam into.
  10. Clean it up with fillet all around.

The Launcher

The launcher wraps around the back of the trophy base with a snug fit. This houses the solenoid and provides a path to the top of the slide. It is basically a big block with trenches dug into it at odd angles. The draft tool is very handy here.

  1. create a sketch on the back side of the trophy base.
  2. project various points from trophy base and the solenoid and the gate.
  3. extrude a new component 10mm, which is deeper than the solenoid.
  4. Make a sketch at the top of this and project bounds of the solenoid top.
  5. Extrude (cut) the cavity where the solenoid will fit. Make it very snug!
  6. Another simple sketch for the top of the slide. A rectangle that covers everything.
  7. Extrude a good 20mm creating a giant block hanging off the back.
  8. Extend some 2mm fins over the top and bottom of the trophy base. Again: a tight fit. This provides a grip to hold the launcher to the back of the case. I made some holes and whatnot for screws but I discovered later that screws are optional. I don't actually use the holes I made, but you can.

The Launcher Trench

  1. Create a simple sketch at the top of the launcher to define the path of direction toward the slide. Its a rectangle.
  2. Dig out 3mm from the top of the launcher with a "cut" extrude.
  3. To insure the slide starts at a good angle you will need to create two drafts:
  4. Realize that the entire launcher tilts at an angle off the back of the case. So use draft to make the trench more horizontal. If you don't do this, you would need high rails on the slide to prevent the pie from falling off during it's joyride. Negative 5 degrees is good.
  5. Create another (steep) 20 degree draft to set the pie into fast motion torward the slide we will make soon.
  6. Clean up the Launcher by removing extraneous material. It is good to make this as light as possible as it sits high on the back of the clock.

Now comes the fun part! ...

Creating the Slide in 3D

The slide is formed from a spline in 3 dimensions. This one is interesting as it is a spline created in a 3D sketch. Most people don't realize that you can create sketches in 3 dimensions.

  1. Create a 2d sketch that is crazy simple:
  2. simply place a single point where you want the the slide to end. It's on the XZ plane a bit to the left of the face plate aligned to the bottom edge.
  3. Start with a 2D sketch in the plane of the side of the Pi trophy. The YZ plane.
  4. Create a point at the top of the slide centered on the bottom edge of the slide starter.
  5. Project the square "U" shape from the existing slide top.
  6. Make the vertical sides high enough to guide objects down the slide. These will be the guide rails that keep the rider from flying off.
  7. Now open up the "Sketch Pallet" and find the check-box "3D Sketch" and check it.
  8. Project the point you made previously on the simple sketch at the bottom of the slide.
  9. Create a spline from the point at the top of the slide to the bottom of the slide.
  10. Experiment with creating one or two control points. I chose to do only one control point. This results in a path for the slide that is rather uniform all the way down.
  11. Create a sweep.
  12. Select the square "U" as the profile.
  13. Select the 3D spline as the path.
  14. Admire your slide.
  15. Maybe go back and adjust the shape of the spline until you like how it looks.

Pie Plate

The platter is thin: 1mm all around. The numbers a subtly embossed 0.5 mm deep.

  1. create a sketch of a circle roughly the size you want the pie plate to be. This is only for reference to help form the spiral-ish pie plate we are making.
  2. Create a new sketch. This is a spiral-ish spline that makes a big circle starting at one edge of the base of the slide around to the other edge of the base of the slide.
  3. Extrude 10mm a new component that forms the basic shape of the tray.
  4. Use the "shell" tool to hollow it with 1mm all around.
  5. I used the draft tool twice to slope the sides 15 degrees outward. This makes it look good but be careful if you plan to send something like small ball bearings down the slide. Balls travel fast and might be launched out of the tray if the side are sloped too much.
  6. The pie plate is decorated with digits from Pi using a spline that is roughly a spiral. The process is pretty much that same as we did for the beginning of Pi way back at the beginning on the front of the case.
  7. Create a spline the shape you like
  8. Use the spline as a path for the long series of numbers this time ending with digit found at 100,000 in Pi.

Step 10: Pie Delivery Electronics

This Sunfounder Display Makes Wiring Simple

The nice thing about the Sunfounder display is that all of the Raspberry Pi pins are exposed on a connector in the same configuration as the actual Raspberry Pi connector. If you have a different display, you might need to make these connections using wire wrap.

Raspberry Pi Wires

Using female to male jumpers wire the GPIO to the control end of the relay.

  • Pi 5V to relay VCC
  • Pi GPIO4 to relay IN
  • Pi GND to relay GND

Solenoid Wires

The solenoid is mounted hidden inside the top of the slide. It has a red wire (plus) and a black wire (minus). The relay acts as a switch that enables contact from the 9 volt battery black wire wire (minus) to the solenoid black wire. The two red wires are directly connected to each other from battery to solenoid. Like this:

  • Solenoid red to Battery red
  • Battery black to Relay NO (normally open)
  • Relay COM to Solenoid black

Pie Delivery Button

Sometimes you will want to show your friends the clock but you don't want to wait for 3:15 to show the action. Sometimes, you will need to test the pie in the slide. And sometimes you just want to play all day! So I added a switch to release the pie any time you want.

  1. Load pie in the top of the slide
  2. Press the switch
  3. Watch the pie take a ride.

I used a small momentary button switch.

  1. I soldered two thin wire-wrap wires to opposite corners of the switch.
  2. The other end of the wires connect to the output of the solenoid in exactly the same holes as the solenoid and battery are inserted.
  3. It is that simple. There are no special electronics: just a switch. Done.

The switch does exactly the same thing that the relay does: it connects the 9 volt battery to power the solenoid and releases the pie.

Pie Delivery Command, FYI

If you have not wired this extra button, you can also run a command on the Raspberry Pi to enable the slide.

First connect to your and get to the shell command line. You can connect a keyboard to the back and run the Terminal. Or connect using ssh. This is how I connect with ssh at my house:

ssh pi@pi-click.local

Then run this:

python pi-clock/pi-delivery/deliver.py

The gate will open for one second and release the pie.

Step 11: Software Explained

The software is broken into two parts:

  1. A python script that I used to preprocess (scrape) the data.
  2. A javascript program that runs on the Raspberry Pi in a browser.

100,000 Digits of Pi

I downloaded 100,000 digits of Pi from angio.net and added a bit of formatting to convert it to a javascript array.

const pistringRaw = "3.141592653589793238462643...


Python Preprocessing


I wrote a python script that generates a lookup table from data in the text file of digits from angio.net. There should be no reason that you need need to run this python script. I only included it for reference to show you how I generated the data.

The script is fairly simple:

  • For every minute of the day:
  • Search for the first instance of this 4-digit number in all the digits of Pi. And save the position (index) in the giant string of Pi values.
  • After finding the hours/minutes value, start searching nearby for all 2-digit numbers 00 through 59. These are the seconds.
  • After finding all the seconds in that minute, sort the seconds based on position of the digit in Pi. The value farthest from the beginning of Pi is saved first. My goal is to make the javascript as simple as possible. Saving the deepest value first, simplifies the javascript. More on that later.
  • Each index of the seconds is saved with a unique string. This string will be used later in the javascript to identify a <span> element. Again, more on that later.
  • After applying a little boilerplate, the result is a javascript lookup table. I saved the results to a file named piclockdata.js. You will notice that index.html imports this file when the webpage is loaded.

The output looks like this:



piClockData = {
"0000":[13391,[
[14013, "sec54"],
[13911, "sec40"],
[13810, "sec34"],
[13794, "sec58"],
[13791, "sec18"],
[13784, "sec55"],
[13774, "sec42"],
[13769, "sec59"],
[13763, "sec27"],
[13747, "sec41"],
...
"2359":[20308,[
[20990, "sec44"],
[20854, "sec40"],
[20849, "sec58"],
[20846, "sec31"],
[20769, "sec59"],
[20765, "sec55"],
[20756, "sec03"],
[20728, "sec53"],
[20717, "sec42"],
[20707, "sec54"],
[20701, "sec41"],
[20680, "sec57"],
[20652, "sec20"],
[20645, "sec34"],
[20639, "sec36"],
[20627, "sec50"],
[20623, "sec35"],
[20609, "sec29"],
[20605, "sec48"],
[20594, "sec27"],
[20591, "sec37"],
[20580, "sec14"],
[20575, "sec10"],
[20571, "sec05"],
[20567, "sec16"],
[20562, "sec43"],
[20559, "sec09"],
[20554, "sec30"],
[20549, "sec13"],
[20544, "sec08"],
[20538, "sec51"],
[20531, "sec00"],
[20528, "sec38"],
[20523, "sec32"],
[20518, "sec47"],
[20513, "sec46"],
[20507, "sec52"],
[20503, "sec22"],
[20500, "sec19"],
[20496, "sec11"],
[20492, "sec02"],
[20489, "sec04"],
[20486, "sec06"],
[20482, "sec28"],
[20479, "sec25"],
[20474, "sec56"],
[20470, "sec23"],
[20466, "sec21"],
[20460, "sec07"],
[20455, "sec49"],
[20451, "sec39"],
[20447, "sec17"],
[20438, "sec26"],
[20432, "sec01"],
[20429, "sec15"],
[20424, "sec33"],
[20419, "sec18"],
[20415, "sec24"],
[20412, "sec12"],
[20408, "sec45"],
]],
} // piClockData


(Side note: I also generated the same data for Euler's number. If anyone wants to make an e-clock, it won't be hard.)

Javascript

Among other things, you will notice that index.html imports two data files:

  • pi.js contains 100,000 digits of pi.
  • piclockdata.js contains a lookup table to help find time in the digits of pi. This is the file I generated on my laptop described in the previous section.

The function currentTime() runs once every second. Different events happen at different times.

  • A new webpage is generated once every minute.
  • A <span> element is inserted before the 4-digit time and </span> inserted after it. The id is named "now".
  • This span has a unique color and size to make it stand out from the rest of the digits.
  • Another sixty <span> elements are populated. These are the seconds. Each one has a unique identifier that always begin with "sec" and ends with a two digit number "00" through "59". These id values are readily available in the lookup table piClockData{}.
  • Each second of the day the appropriate two-digit value briefly changes color. All we need to do to adjust the color is apply a new value to the <span> identifier created when the current minute rolled in.

If you are curious, you can open up the debug tools in a browser. It will look something like this for example:

12:36


472645539925399442808113736943388729406307926159599546262462970706259484556903471197299640908941805953439325
<span id="now">1236</span>
235508134949004364278527138315912568989295196427287573946914272534366941532361004537304881985517
<span id="sec06" style="color: rgb(88, 136, 166);">06</span>
594
<span id="sec12" style="color: rgb(88, 136, 166);">12</span>
1735
<span id="sec24" style="color: rgb(88, 136, 166);">24</span>
6
<span id="sec25" style="color: rgb(88, 136, 166);">25</span>
895
<span id="sec48" style="color: rgb(88, 136, 166);">48</span>
73
<span id="sec01" style="color: rgb(88, 136, 166);">01</span>
676
<span id="sec00" style="color: rgb(88, 136, 166);">00</span>
29886
<span id="sec59" style="color: rgb(88, 136, 166);">

Step 12: One Hundred Thousand Digits of Pi

Mesmerizing

I find myself distracted, mesmerized, as I stare at the seconds tick by, anticipating a new minute to slide in. Every once in a while I will scroll with my finger to the top, curious as to just how deep into Pi it is. Most often I'm surprised how close to 3.14 it is -- but not always.

I'll wait for "55, 56, 57, 58, 59" to tick into place -- waiting for that magic scroll. Sometimes the screen slides just a tiny bit. Occasionally it scrolls a long way away to totally new section of Pi.

Fun Facts!

  • The last digit used by the clock finishes at index 61,489 (digit 61,487) at 12:03:55
  • The first time found in Pi on a 24-hour clock is 14:15 (of course!)
  • The first time found in Pi on a 12-hour clock is 10:58 which is found in the digit sequence at 48 through 51 after the decimal point.
  • The last 4 digits of the 100,000 are "2464". I wonder what is next!

Skeptical About All Those Digits of Pi

Scientists around the world are probably reading this Instructable and cringing. Most would say 100,000 digits of Pi is completely unnecessary!

For instance, a good scientist and educator would point you to this interesting Instructable: Pi Approximation With Raspberry Pi (Monte Carlo Method). Notice that the demonstrated approximation renders a pretty nice circle from just a few digits of Pi.

So, for most: a handful of digits should be just fine. Like: 3.14 or maybe 3.1416.

On the other hand, if you want to be an astronaut or an astronomer maybe you want to use 15 digits. Take a look at what NASA has to say about it on their Jet Propulsion Laboratory website.

For JPL's highest accuracy calculations, which are for interplanetary navigation, we use 3.141592653589793.

They go on to say that you would need about 37 digits to plot a circle around the know universe to the accuracy of a diameter of a hydrogen atom.

(On the other hand: Euler's number, e, has a totally different story. There are many scientists who treasure many of digits in that number. As they say: it is, of course, all in the i of the e-holder!)

Proof Positive: A Clock

But for those who are willing to think outside the circle, I hope I have proven beyond a doubt that 100,000 digits is actually practical. This Pi Clock could not have been built without it!

Step 13: Looking Ahead to the Future

All of the above reflects the current state of the Pi Clock. So what's next? In this section I will try to document issiues, problems, missing features, or anything that could make this a better clock or better Instructable.

Here is a short list of what I'm thinking:

  • Occasionally, the piece of pie is reluctant to go down the chute. It works most of the times but not 100%. Odds this can be fixed with and updated design of the tiny "gate". If I come up with a better design, I will post the STL file.
  • I don't like the gigantic relay that I used in the project. Initial experiments reveal that SunFounder Relay Module from Amazon seems to work well but it won't fit on the current relay holder. Expect a redesign of the relay holder to accommodate this smaller part. Stay tuned..
  • The button to manually trigger the gate to release the pie is in an awkward location. I'll see if I can move it in a new design of the relay holder.
  • Update: On April 29, 2024 I posted a new version of pi-gate.stl. It seems to be better than version 1.
  • My one-man operation lacks a proper QE team. In an effort to recruit low-wage workers I'm thinking one or more the the following additions would be good. I'm thinking free labor:
  • Connect to a Makey Makey so this can be tested while eating real pie!
  • Connect to my granddaughter's Snap Circuits kit. She might think she is playing, but she is actually working. Yeah: free labor!
  • I designed the pie plate for PLA pie but marbles could be fun too. If I send a tiny marble (ball bearing) down the chute, it will often fly out of the pie plate and launch itself airborn to the other end of the room. Maybe higher walls on the platter. Or an overhang. Something. If I come up with a better design, I will post it.
  • Every time I scan this Instructable, I see a new typo. Odds are I will add more tweeks.

Add a comment if something is wrong or if you need something from me. I'll get back to you. I'm sure there are more things that need attention.

Thanks!

All Things Pi Contest

This is an entry in the
All Things Pi Contest