Cookie of the Day
Hello Everyone.
As a computer science student, I spend most of my day sitting at my desk—writing code, staring at a screen, and almost always eating a cookie.
The problem is… I have a huge selection of cookies and somehow, deciding which one to eat turns into a bigger challenge than the actual coding.
So instead of making a normal, adult decision, I did what made more sense: I built a Raspberry Pi–powered system with a custom app to decide for me.
I turned my daily cookie habit into a project. I designed and 3D-printed a giant cookie, divided it into 14 sections, and used a Raspberry Pi to pick a Cookie of the Day.
Every day, it chooses one cookie—or, if I’m feeling indecisive, I can press the Shuffle Cookie button to get a random pick. It saves me from the tedious task of choosing a cookie myself. It’s simple, a little silly, and honestly, kind of fun
Supplies
These are the components used in this project:
- Raspberry Pi 4
- DFROBOT 5 Inch HDMI Touch screen DSI
- MicroSD card with Raspberry Pi OS installed
- 12V to 5V Buck Converter
- DC Barrel Jack
- HDMI
- Wi-Fi connection (optional, only for setup)
- Keyboard & mouse (or SSH from another computer)
- 3D Printed parts
- Brown Spray Paint
- Automotive Filler
- M2 screws
- M2.5 Bolts
- M3 screws
- M4 Bolts and nuts
Electronics- Raspberry Pi 4 With Display
As for the electronics, we used a Raspberry Pi 4B+ (4 GB variant) for this project, which handles our custom cookie application.
To display the cookie app UI, we selected DFRobot’s 5-inch DSI touch display, which connects directly to the Pi’s DSI connector.
For powering both the Raspberry Pi and the display, we chose a 12 V adapter for our Cookie Picker project. However, the Raspberry Pi is a 5 V device and cannot accept 12 V directly.
To solve this, we used a 12 V-to-5 V, 3 A buck converter, which steps down the adapter’s 12 V supply and provides a stable 5 V output for the Pi to function properly.
RASPBERRY PI DISPLAY SETUP
We begin the Raspberry Pi 4 and display assembly process by aligning the Raspberry Pi over the display’s mounting bosses located on the back of the panel. These bosses use four M2.5 bolts, which we use to securely fasten the Raspberry Pi in place.
Next, we connect the provided DSI FPC cable. The cable is first inserted into the display’s DSI connector, and then the other end is connected to the Raspberry Pi’s DSI port. During this step, we make sure the FPC cable is inserted in the correct orientation. The 5-inch display’s official wiki page was extremely helpful in ensuring this connection was done correctly.
For the power source assembly, we use a 12 V to 5 V, 3 A DC-DC buck converter. A DC barrel jack is connected to the input side of the converter, while a CON2 JST connector is added to the output. This JST connector is then connected to the 5 V and GND pins on the Raspberry Pi’s GPIO header. When 12 V is supplied through the barrel jack, the buck converter provides a stable 5 V output, allowing both the Raspberry Pi and the display to operate reliably.
3D MODEL
Our goal for this project was to build a wall-mounted shelf that could store cookies while also housing a Raspberry Pi setup to display our cookie app. Since we were essentially designing a cookie shelf, the most natural shape that came to mind was a round shelf that resembles a cookie.
I originally wanted to make it Oreo-themed, but due to some technical limitations, that didn’t quite work out this time. It’s definitely something I’ll revisit in a future version.
We started by taking measurements of all the cookie packets we purchased. The largest packet we recorded measured 190 × 60 × 60 mm. Using this as the maximum reference size, we designed every partition on the shelf to be slightly larger than the biggest cookie packet.
In total, we created 20 partitions. The largest partition measures 200 × 133 × 80 mm, while the smallest is 110 × 80 × 80 mm. This allows each compartment to comfortably hold cookie packets ranging from small to large sizes.
In the bottom-center section of the shelf, we positioned the Raspberry Pi display assembly. The Pi is first secured to a dedicated Pi holder, which is then mounted onto the cookie shelf. We also added a hole at the bottom of the shelf to mount a DC barrel jack for powering the Raspberry Pi.
Since the overall model measures 730 mm in diameter, it is quite large. Our 3D printer has a build volume of 250 × 250 × 250 mm, so we had to divide the model into multiple parts and assemble them afterward. Using glue was not a reliable option at this scale, so each divided section includes mounting holes for M3 nuts and bolts, allowing all the parts to be securely fastened together to form one large, round cookie shelf.
To prevent cookie packets from falling out of their compartments, we added a retaining rail to the front of each partition. Each rail is secured in place using two M2 screws.
3D Parts
Using our Anycubic Kobra S1 3D printer, we printed each part one by one using the Hyper PLA filament we had on hand. The entire build required multiple filament rolls—five rolls in total.
For the main body, we used whatever filament colors were available, ranging from white to grey and even brown. For the Raspberry Pi holder and the retaining rails, we switched to white Hyper PLA to create a clean, two-tone color contrast.
All parts were printed with a 0.4 mm nozzle, sliced at 25% infill, and printed at 300 mm/s, which resulted in a print time of roughly 9–10 hours per main section.
The retaining rails and the Pi holder were much smaller and printed in under 3 hours each.
Assembly Process
We start the assembly process by positioning two partitions together. Using the mounting holes for proper alignment, we secure them with two M3 nuts and bolts. This step is then repeated for all the remaining partitions.
Once all the partitions are joined, the result is a single, large, circular cookie shelf forming the main body of the project.
SURFACE FINISH - FILLER, SANDING, PAINT
The next step is the surface finishing process, which is a crucial stage since we plan to paint the entire 3D-printed shelf. Painting directly on a raw 3D print is not ideal, as visible layer lines and gaps between parts would still show through. To achieve a smooth and uniform finish, proper sanding and gap filling are required.
- We begin with the filler process, using an automotive body filler that comes with a filler compound and a hardener. A small batch is mixed first, following the ratio specified on the packaging. Using a 3D-printed scraper tool, the filler is applied to the gaps between partitions and to any areas that appear warped, uneven, or have poorly defined layer lines.
- After allowing the filler to fully cure, we start sanding using coarse-grit sandpaper to remove excess filler and level the surface. This is followed by fine-grit sandpaper to smooth things out. This filler-and-sanding process is repeated twice to achieve better results.
- Once the surface is reasonably smooth, we apply a coat of spray primer to the entire 3D-printed shelf. The primer is left to dry for a full day. After drying, a second sanding pass is done using fine-grit sandpaper to further smooth the surface and eliminate any remaining imperfections or gaps.
- After thoroughly wiping the model with a dry cloth to remove dust, we move on to the final paint process. Using brown spray paint, we apply the first coat and let it dry for a day. A second and final coat is then applied, completing the surface finishing process.
FINAL ASSEMBLY
- We began the final assembly by placing each retaining rail (all 20 of them) into its respective partition. Each rail was secured using two M2 screws, firmly holding them in place.
- Next, we routed the DC buck converter wiring through the hole on the bottom side of the shelf and mounted the DC barrel jack in its designated position.
- After that, we connected the DC–DC buck converter’s output via a JST connector to the Raspberry Pi’s 5 V and GND GPIO pins. This allows the Raspberry Pi to be powered safely through the buck converter.
- Finally, the Raspberry Pi holder was placed in position and secured using two M3 screws, completing the assembly process.
RASPBERRY PI APPLICATION SETUP
Boot into Raspberry Pi OS
Connect to Wi-Fi
Open a terminal
Update the system
Install GUI support library
Create the project folder
COOKIE SCRIPT
Before we begin writing the script, we need some images of the cookies. For that, I first went to a local market and gathered all my favorite cookies (all 12 of them) specifically for this project.
Next, I searched for clean, well-rendered images of the cookies I collected, which will be displayed in our application.
This is how it works: basically, we have a folder called “images” that contains all the cookie images. That’s all we need, along with a Python script to run the program.
Here, we have used Python and Tkinter for this app, it uses a simple JSON file to store the selected cookie and the time it was chosen. On every launch, the program checks this file. If less than 24 hours have passed, the same cookie is displayed again. If more than 24 hours have passed, a new cookie is randomly selected and saved.
Using the above command, we can easily launch our application.
Autostart on Boot
We use the above command to create the AutoStart folder. The operating system looks inside this folder to determine which applications should run automatically on boot.
The -p flag ensures that the command won’t fail if the folder already exists.
This command opens a file named cookie_of_the_day.desktop using the Nano text editor. A .desktop file tells the system which program to run, how to run it, and when it should be launched.
Next, we paste the above desktop entry into the file, which defines the application name and the command that will be executed automatically at startup, and then save the file.
Using sudo reboot, we restart the device.
RESULT
After completing the assembly process, our project was ready for its first test run. We began by mounting the unit on a wall using the provided mounting holes, secured with two nails placed 127 mm apart.
Next, we loaded all of our cookie stock into their respective partitions and connected a 12 V adapter to the DC barrel jack, which powers the Raspberry Pi and the display setup.
After a few seconds, the Raspberry Pi boots up and goes straight into our app’s user interface.
RANDOM COOKIE GENERATOR
Once the UI is loaded, the app is fully functional and displays a cookie for the day. If we want something different, we can simply press the Shuffle Cookie button, which selects a new cookie for us.
We tried this again the next day, and the app once again generated a fresh cookie selection completely freeing us from having to think about which cookie to choose.
CONCLUSION AND WHAT'S NEXT?
The Cookie of the Day works exactly as intended. The app randomly selects a cookie for us, saving us from the tedious task of choosing one ourselves. It’s simple, a little silly, and honestly kind of fun.
This wasn’t a real problem that needed solving. It was just a tiny everyday dilemma, and this project was my excuse to solve it using a mix of computer science, electronics, and 3D printing.
Naturally, the next iteration would be taking this a step further, actually dispensing the selected cookie. At that point, it starts to feel less like a randomizer and more like a tiny vending machine or kiosk.
But for now, this is where the project ends.
If you’ve made it this far, thank you for sticking around. Stay tuned for the next build.
Bye.