The Pi Day Raspberry Pi Pie Picker
by mike_o8 in Circuits > Raspberry Pi
1081 Views, 1 Favorites, 0 Comments
The Pi Day Raspberry Pi Pie Picker
As pi day approaches many of us are faced with the decision of what pie to eat on this most wonderful mathematically perfect day. To overcome this problem, I present to you The Pi Day Raspberry Pi Pie Picker!
No more do we need to agonize over our pie choice.
No more do we need to worry that we will miss out on one pie when we eat another.
No more do we have to stand in front of the desert case at our local diner or the freezer case at our local grocery store in indecision.
With this simple device, all the problems of choosing which pie is removed and with the press of a button your decision is made and you can be about eating your beloved pie.
Ladies and gentlemen. I give you The Pi Day Raspberry Pi Pie Picker. To see it work skip to the last step. To make one of your own, read on.
Assemble Your Ingredients
Parts wise, you probably already have all the parts needed for this project just laying around.
Parts List:
- Raspberry Pi (you could use an Arduino but it is not Arduino day)
- LEDs - The number and colors are completely up to you but eight seems like a nice round number here
- Resistors (I like the 220 ohm flavors) - You need as many resistors as you LEDs
- Normally Open Push Button Switches - You need two of these if you want a reset button, one if you do not
- Write - You have to connect it together somehow
- Display Board - This needs to be big enough to hold all your choices. You can make it out of anything, but it should not be thicker than your LEDs
- Breadboard - Really, you don't need this, but it will make cooking up this project just a little easier
Tools/Supplies
- Soldering Iron
- Solder
- Glue
- Pen
- Drill/Bits
- Tape
Cook the Crust
This display is made out of a 1/8 inch board. It worked OK, but I had trouble with the final lettering. If I were to do this again I would look at either other materials or a different type of ink.
You will need to make a rough layout of where you want the lights and buttons. Using a light colored pencil and a ruler, draw guidelines marking where the lights, buttons, and lettering will go.
Once you have your design laid out you will need to drill some holes. For the LEDs, I used a 3/16 inch drill bit and a 1/16 inch drill bit for the leads of the buttons.
Insert your LEDs and glue them down. I aligned the anode leads to the inside and the cathode leads to the outside. This made it easy to wire everything together. Before you start wiring everything together, write your pie choices on the front of your display board.
When the glue is dry, break out the soldering iron.
Prepare the Filling
Take a look at the attached schematic. The wiring is pretty straightforward.
Start by soldering your cathode leads together. Run the ground wire to one side of each of your push buttons as well.
Clip the anode leads and all of the resistor leads down to a reasonable size. Solder a resistor to the anode end of each LED. To the other end of each resistor attach a lead that will connect to the breadboard.
The last thing you will need to do is connect a lead to the opposite side of each push button as the ground wire is connected to.
On the breadboard side of things, attach your ground wire to the ground bus. Attach the other leads to the breadboard in whatever order makes you happy.
Next up is the connection to the Raspberry Pi. The attached schematic shows which pins you will need to connect to if you use the code from the next step.
Set the Table
The Basics:
Like any pie recipe, this one is open for interpretation. The code is pretty well documented so making changes should be pretty easy.
If you want to make a few changes, read on. I've explained the constants you need to change below.
Once you have the file saved on your device and have made the changes you want, enter the commands below in a terminal to compile the program.
g++ /YourPath/RandomLED.c -o RandomLED -lwiringPi
If there are no errors, you can run the program by entering the following in a terminal window:
sudo ./RandomLED
Operation:
The program starts up and your green "Ready" light will be lit. Press the "Pick A Pie" button to start the lights. Once your choice is made and your light is flashing you can press and hold the "Reset" button to reset the lights and try again. Of course, the whole point of the Pi Day Raspberry Pi Pie Picker is to make the choice for you so you really shouldn't be pressing the reset button unless you want to show off how cool your project is.
Code Explanation:
The program starts by checking if you have WiringPi installed. If you don't, you will need to get loaded. Follow the instructions on the designer's website.
Five constants control the speed of the lights and how fast they slow down.
- firstSpeed: this is the starting delay in milliseconds that your lights will stay on
- lastSpeed: this is the slowest delay between lights before the final round and choice is shown
- slowSpeed: this is the speed of the final round before the choice is shown
- speedInc: this is the number (in milliseconds) that the lights will slow down between cycles. The second cycle of lights will be this number of milliseconds slower than the first round. The delay increases speedInc/8 milliseconds between each light
- blinkSpeed: this is the speed with with the final choice blinks
Downloads
Dig In
That is it. You are ready to go. When you need to know which pie to eat, just press the button. Remember though: Whatever the Pi Day Raspberry Pi Pie Picker picks must be obeyed.
Enjoy your pie.