DrinkTimer: Smart LED Timer for Your Party – DIY Project With NeoPixel, Raspberry Pi Pico, and MicroPython [Guide + Code]
by ulmerju in Circuits > Electronics
424 Views, 4 Favorites, 0 Comments
DrinkTimer: Smart LED Timer for Your Party – DIY Project With NeoPixel, Raspberry Pi Pico, and MicroPython [Guide + Code]
The DrinkTimer is a DIY project designed specifically for parties. Powered by a Raspberry Pi Pico and programmed in MicroPython, the DrinkTimer measures the time a glass is lifted and, ideally, emptied. The duration is displayed on an OLED screen, which also shows the current time, fastest, and average drinking times.
The experience is enhanced with NeoPixel LED rings, creating vibrant light shows that amplify the party atmosphere. Additionally, a plotter and 3D printer were used to craft the enclosure and other components. This project not only adds a fun element to your next party but also offers a fantastic opportunity to delve into the world of microcontrollers and creative electronics.
Supplies
- Raspberry Pi Pico
- NeoPixel LED Ring(s) (e.g., 1/8/16/24/35/4 ... Leds LEDs per ring)
- OLED Display (e.g., 128x64 pixels, I2C)
- Round acrylic glass (for protective or aesthetic covers)
- Diffuser film (to soften and spread the light from the LEDs)
- 2x Touch Sensor
- 3D-printed enclosure
- Jumper wires
- Resistor (330 Ohm)
- Capacitor (1000µF, 6.3V or higher)
- USB cable for Raspberry Pi Pico
- Breadboard or soldering materials
Set Up the Hardware
Connect the LED Ring:
- Connect the DIN pin of the NeoPixel ring to one of the GPIO pins of the Raspberry Pi Pico (e.g., PIN32 (GP27)).
- Connect VCC to 5V and GND to GND on the Pico.
- Add a 330-ohm resistor between the GPIO pin and the DIN pin of the LEDs.
- Place a 1000µF capacitor between VCC and GND to minimize voltage fluctuations.
Connect the OLED Display:
- Connect the SDA and SCL pins of the OLED display to the corresponding I2C pins on the Pico (e.g., PIN4 (GP2) for SDA, PIN5 (GP3) for SCL).
- Connect VCC and GND to the respective pins on the Pico.
Touch Sensor for Start and Object Detection:
- Connect the output of Sensor1 to (e.g., PIN34 (GP28)), and VCC and GND to the corresponding pins on the Pico.
- Connect the output of Sensor2 to (e.g., PIN24 (GP18)), and VCC and GND to the corresponding pins on the Pico.
Optional:
- Use a breadboard for temporary connections before soldering everything together.
Prepare the Software
Install MicroPython on the Pico:
- Connect the Pico to your computer via a USB cable.
- Install the MicroPython firmware on the Pico by dragging the firmware file onto the Pico "drive."
Develop the Code:
- Open a MicroPython IDE (e.g., Thonny) and begin writing the code for the DrinkTimer.
- Utilize libraries like neopixel for controlling the LEDs and ssd1306 for the OLED display.
- Implement the functionality for time tracking, LED light shows, and display output.
Upload the Code to the Pico:
- Test the code within the IDE to ensure it works properly.
- Once finalized, upload the code to the Pico.
_________________________________________________________________
Alternative:
- Use the provided files and save them directly to the Pico.
Special Considerations:
- The LED ring animations are stored in an external class, allowing for easy expansion and customization.
- The OLED display typically only supports small fonts. Therefore, the writer.py function and freesans20.py are used to generate custom writer files and fonts that allow for larger text display.
3D-Print the Case
Design a custom enclosure or use a pre-made template that provides space for the Raspberry Pi Pico, the LED ring, and the OLED display. Use a 3D printer to create the case and ensure it accommodates all components securely.
For my project, I cut a 140mm diameter disc from acrylic glass and printed a matching case using a 3D printer. The case consists of two main components:
- Lid Element: The acrylic glass disc is glued into the lid, which creates a sleek and modern appearance.
- Base Element: This part houses all the electronics, including the Raspberry Pi Pico, the LED ring, and the OLED display.
The lid fits precisely onto the base and can be secured with slight pressure, ensuring a snug fit without the need for screws or additional fasteners.
To enhance the visual effect, I used a plotter to cut a 140mm ring from translucent, diffuse film with a window for the OLED display. The film was applied to the acrylic glass, diffusing the light from the LEDs and giving the animations a much smoother, more attractive appearance. This added touch makes the LED effects look even more impressive and professional.
Optionally, you can use a plotter to create custom decorations or labels for the case, giving it a personalized touch.
Assembly and Testing
Now that all components are prepared, it’s time to assemble your DrinkTimer and bring it to life.
- Place the Electronics: Carefully position the Raspberry Pi Pico, the OLED display, and the NeoPixel ring inside the 3D-printed case. Ensure each component fits snugly in its designated area to avoid unnecessary movement or strain on the connections.
- Secure the Components: Once everything is in place, secure the components to the housing. You can use small screws for a more permanent installation or hot glue for a quicker, adjustable setup. Make sure that the LED ring is aligned correctly, and the OLED display is visible through the window in the acrylic disc.
- Connect and Power On: With the components secured, it’s time to connect the wiring according to your setup. Attach the power supply and double-check that all connections are correct, ensuring that both the LEDs and the OLED display are properly linked to the Raspberry Pi Pico.
- Test the DrinkTimer: Power on the device and watch as it springs to life. Verify that the NeoPixel LEDs light up as expected and display your programmed animations smoothly. Ensure that the OLED display shows the desired information, such as timers or notifications.
- Final Adjustments: During testing, check for any potential issues. Are the LEDs displaying the correct colors and sequences? Is the OLED screen clear and legible? If everything works as intended, your DrinkTimer is now fully functional and ready for use!
With the assembly complete, you’ve transformed your design into a working device that combines functionality and style.
Final Adjustments and Enjoying Your Project
With your DrinkTimer assembled, it’s time for the final touches and customizations to make your project truly unique.
- Customize LED Light Shows and Effects:
- Experiment with different light patterns and animations for the NeoPixel rings. Play with colors, brightness, and timing to create unique and exciting effects. You can even design personalized LED animations to add a special touch or create celebratory animations for when a player wins the game.
- Optimize the Display:
- Fine-tune how the information is displayed on the OLED screen. Adjust the readability of the timer, or customize messages that appear based on game progress. Add celebratory messages or animations to highlight key moments, such as announcing the winner or reaching game milestones.
- Enhance the Design:
- Add decorative elements or labels to polish the design of your DrinkTimer. Using custom engravings, stickers, or other creative decorations, you can give the project a personal, finished look. Consider adding extra features like sound effects or vibrations for more interactive fun.
Enjoy Your DrinkTimer
Now it’s time to show off your DrinkTimer at your next party! Use it to track game progress, impress your friends with the cool LED effects, and dynamic display animations.
Don’t stop here—continue to experiment with new features and improvements. Whether it’s more complex light shows, integrating sound, or expanding the display functionality, your DrinkTimer can evolve with your creativity. The possibilities for fun and personalization are endless!