Engineering a Rust-Powered Graduation Cap
Graduation ceremonies are steeped in tradition, from the ceremonial moving of the tassel to the expensive rental of caps and gowns. For most, it is a day of reflection and celebration. For Eric Park, it was an opportunity to integrate embedded systems and a specific programming language into a piece of ceremonial headwear.
What started as a critique of the arbitrary nature of graduation traditions evolved into a technical challenge: creating a cap that detects tassel movement and triggers a light show. The result is a project that blends hardware hacking, embedded Rust, and a healthy dose of academic irony.
The Hardware Stack
Building a wearable device requires a balance between functionality and form factor. To keep the cap lightweight and avoid the bulk of a larger microcontroller like the ESP32, Park opted for a minimal hardware footprint.
Component Breakdown
- Microcontroller: Digispark ATtiny85. Chosen for its small size and low cost, making it ideal for projects requiring only a few GPIO pins.
- Lighting: 48 WS2812B LEDs. These addressable LEDs allow for complex patterns and colors to be programmed individually.
- Sensors: A reed switch and magnet. This combination acts as the trigger; when the tassel is moved, the magnet moves away from the reed switch, signaling the microcontroller to activate the LEDs.
- Power Management: A USB-C Power Delivery trigger board paired with a power bank. This ensures the LEDs receive consistent power without requiring a bulky battery pack integrated into the cap fabric.
- Wiring: Stripped wires from a discarded Apple USB-C-to-C cable, demonstrating a resourceful approach to sourcing materials.
Implementing Rust on the ATtiny85
While the hardware was straightforward, the software presented a unique challenge. The primary motivation for using Rust was not necessarily technical necessity—Park admitted he was "married to the blog post title idea"—but the implementation revealed the friction points of using Rust in highly constrained embedded environments.
Overcoming HAL Limitations
Writing the code took approximately two hours, but much of that time was spent dealing with library compatibility. The avr-hal and ws2812-avr crates do not support the ATtiny85 out of the box. To make the project viable, Park had to:
- Fork the libraries: Creating custom versions of the HAL (Hardware Abstraction Layer) to accommodate the specific architecture of the ATtiny85.
- Apply "dirty-patches": Manually adjusting configurations, including setting the default clock speed to 16 MHz to ensure the timing-sensitive WS2812B LEDs functioned correctly.
This highlights a common theme in the Rust embedded ecosystem: while the language provides immense safety and power, the support for older or more niche AVR chips often requires manual intervention and a willingness to dive into the underlying HAL code.
Reflections on the Build
Hardware development is rarely as seamless as software. Park noted that while the code took two hours, the physical assembly took over three, reinforcing the adage that hardware is where the "real" difficulty lies in mechatronics.
The "Tacky" Dilemma
Despite the technical success, the project faced a design hurdle: aesthetics. Park ultimately decided not to wear the device to the actual ceremony, describing the result as looking like "what kids would think of as a gaming PC and what boomers would think of as a seizure." This decision sparked a debate among observers, with some suggesting that wearing it would have cemented his status as a "school legend."
Community Perspectives
The project resonated with the Hacker News community, sparking discussions that ranged from the technical to the systemic.
On Technical Pedantry
As is common in technical forums, some users pointed out the semantic distinction between the language and the execution:
"No it doesn't [run Rust], it runs machine code... Technically it runs AVR-RISC."
On the Economics of Education
Beyond the code, the project highlighted the frustrations surrounding the cost of graduation. Park's experience of paying $94 to rent a cap and gown—with no option to buy—prompted a wider discussion on the "wealth transfer" from students to corporations within the US university system. Some users suggested alternatives like third-party costumes or simply skipping the ceremony entirely to avoid the expense.
Conclusion
The "Rust-powered graduation cap" is more than just a quirky piece of headwear; it is a testament to the joy of building for the sake of building. By forcing a modern language into a constrained legacy chip, Park demonstrated both the flexibility of Rust and the persistent challenges of embedded hardware integration.