Pi Powered Pie Partitioning and Polygon Pruning Tool

5,220

29

4

Introduction: Pi Powered Pie Partitioning and Polygon Pruning Tool

Have you ever served pie and had kids complain that someone else got a slightly bigger piece? Or maybe you want to create a cool 7-sided polygon from a boring round cake. Well now there is a way to scientifically ensure that your pie slices are cut to exactly the same size or that your cake polygon is perfectly dimensioned – all within 1/16 inch accuracy! I speak, of course, of the “Pi Powered Pie Partitioning and Polygon Pruning Tool”. While you might expect to see this space-age marvel show up on “Shark Tank” or late night TV ads for tens of dollars, I’m here to show how you can make your own for just a fraction of that cost. Even better, it will become the envy of your neighborhood and help to make your parties an A-list rated invitation.

Step 1: Measurement Technique

1. Turn on the electronics. It will prompt for the circle diameter.

2. Use the tape measure to get the circle diameter in inches and sixteenths of inches.

3. Enter the diameter measurement into the electronics.

4. Press and hold one of the data entry buttons for greater than one second.

5. The electronics will prompt for the number of slices. Note that the sixteenths button is disabled during this step.

6. After entering the number of slices, press and hold one of the data entry buttons for greater than one second.

7. The electronics will display the chord length. Use that number and the tape measure to mark the edge of the circle.

8. Slice the pie or prune the cake based on the marks you made on the edge.

9. If you want to do another calculation, press and hold one of the data entry buttons for greater than one second.

Step 2: Warning: Math Ahead

The math behind the electronics is, obviously, based on a circle. In order to calculate where to cut the pie or cake we need to figure out something called a “chord”. A chord is simply the straight line distance between two points on the edge of a circle. To partition a circle into equal parts you calculate the chord length and then measure from point to point on the circle edge. In effect, that creates a symmetrical polygon of “n” sides that fits exactly inside of the circle.

To calculate the chord length we need either the radius (distance from the center to the edge) or the diameter (distance from edge to edge that passes through the center). Often, the diameter is just represented in formulas as “2r” (two times the radius). The other thing we need to know is the angle of the circle “slice” we want to cut. Since we are divvying up the circle into equal size pieces, the angle (in degrees) is simply “360 / n”, where “n” is the number of slices. From there we let the magic of math do its thing. The formula for a chord length is: “2r * sin(angle/2)”

So where does Pi come in? Well, a circle consists of 360 degrees or 2*Pi radians. That means that if we know the angle size in degrees we have to use Pi if we want to convert it to radians. That’s important because the Arduino sine function requires the input angle to be in radians even though most of us think in terms of degrees. Fortunately, the Arduino libraries provide defined constants like PI, TWO_PI, HALF_PI, DEG_TO_RAD, and RAD_TO_DEG to help with circle math.

Step 3: Hardware

The basic hardware consists of a standard tape measure attached to the electronic “brains” of the tool. The electronics box is made up of a battery powered ATtiny85 microcontroller that is connected to data entry switches and an LCD display. Because of the limited number of pins on the ATtiny85, the LCD is driven by an I2C 2-wire interface. Attached to the LCD is a common I2C-to-parallel LCD driver module. Power is provided by a 14500 Li-ion battery. It fits a standard AA battery holder and can be recharged using most 18650 chargers. A small booster board increases the battery voltage to the 5 volts needed by the electronics.

There are three normally open, momentary contact switches used for data entry. The left switch is for 10’s, the middle switch is for 1’s, and the right switch is for 1/16’s. The numbers for each switch will automatically go back to zero after reaching the maximum value. Note that the 1/16’s do not automatically overflow to the 1’s column and the 1’s do not automatically overflow to the 10’s column. All measurements are in inches.

Step 4: Software

The software is pretty simple and consists of the LCD interface, the switch handlers, and the simple math for calculating the chord length. The I2C LCD software uses an old library that was modified a few years ago to add ATtiny85 capability. The software is not being actively updated so I have included all of the necessary files here. Happy Pi Day!!!

Pi Day Speed Challenge

Participated in the
Pi Day Speed Challenge

Be the First to Share

    Recommendations

    • Robots Contest

      Robots Contest
    • Made with Math Contest

      Made with Math Contest
    • 3D Printed Student Design Challenge

      3D Printed Student Design Challenge

    4 Comments

    0
    donvukovic
    donvukovic

    Question 7 months ago

    Where did you get the case ?

    0
    BerenV
    BerenV

    7 months ago

    Very epic, it just so happens that this is a source of contention among my family and I may have to build one ;)
    In this case I’m glad you used an ATTiny instead of a raspberry pi due to the smaller footprint, even though it would have been cool to be powered by a Pi.

    0
    Boomer48
    Boomer48

    Reply 7 months ago

    Thanks. It was just a fun little tongue-in-cheek project specifically for Pi Day. My earlier hobby projects mostly used small PIC micros so after I started playing around with Arduinos I knew I needed to just get down to the bare Atmel chips for my battery operated builds.