Sex Toy Debugging: How a Vibrator Solved a Motorcycle Brake Light's Highway Ghost Problem
Share this article
For motorcyclists, a brake light that flickers erratically isn't just annoying—it's a safety hazard that confuses trailing drivers. This was the challenge faced by the creator of BrakeBright, an aftermarket smart brake light system designed to enhance rider visibility during deceleration. Despite rigorous tuning, a stubborn edge case emerged during long highway rides: at sustained high speeds, the light would occasionally flash without any braking input. The culprit? Not faulty hardware, but the chaotic interplay of physics, engine vibrations, and sensor limitations in the real world.
The Sensor's Blind Spot
At its core, BrakeBright relies on an accelerometer—a "dumb little chip" that blindly reports G-forces without context. As the developer explains, "It just feels G-forces and spits out numbers. Whether that force is from braking, a pothole, or some sketchy engine buzz, the sensor treats it all the same." Initial attempts to smooth this noise involved averaging data over short windows and applying low-pass filters. While this reduced jitter from minor bumps, it failed against high-frequency engine vibrations. Averaging proved vulnerable to outliers, while low-pass filtering struggled with sustained harmonic interference.
The breakthrough came when the developer switched to median filtering, which ignores extreme values and focuses on the central tendency of the data. "The median ignores the outliers and shows you what’s happening in the middle of the data range. That gave me something way closer to the real ride behaviour," they noted. This significantly hardened the system against transient spikes. Yet, during a grueling Glasgow-to-Birmingham motorway test, the flickering resurfaced—exposing a deeper timing flaw.
When Sampling Syncs with Chaos
Engine vibrations operate at precise frequencies. On a 270-degree crank twin running at 5000 RPM, pulses fire every 9ms and 15ms. If the sensor's polling interval accidentally synchronized with these pulses, it amplified rather than filtered the noise. "Suddenly, your brake light thinks you’re slowing down when you're actually just cruising," the developer observed. The solution? Introduce controlled jitter to the sampling interval. By adding randomness to the read timing, the system avoided locking into destructive resonance with engine harmonics. This required meticulous calibration—poll too fast, and you capture static; too slow, and you miss critical deceleration cues.
The Unconventional Test Rig
Real-world validation was time-consuming and geographically impractical. "Motorway is an hour out... Each tweak meant hopping on the bike and carving out hours to test," the developer lamented. The fix? A repurposed vibrator. Mounted to simulate high-frequency engine buzz, it became a bench-testing powerhouse. "I hooked it up to mimic the kind of high-frequency engine vibes you'd get ripping down a motorway. It wasn’t pretty, but it worked." This hack accelerated iteration cycles, turning days of road testing into hours of lab refinement—with a memorable moment when the developer's wife discovered the buzzing setup, leading to shared laughter over its absurd ingenuity.
Adaptive Debouncing: Intelligence Under Fire
The final layer was rethinking the trigger logic. Instead of reacting instantly to suspected deceleration, the system now imposes a dynamic debounce delay. If sensor readings suggest braking, it pauses briefly to confirm the signal persists. Crucially, the debounce window adapts based on recent triggers. "If the light turns on and shuts off in under a second, the system assumes a false positive... It bumps up the debounce for next time," the developer explains. When conditions stabilize, the delay shortens again, ensuring responsiveness during genuine braking. This self-tuning approach balances noise immunity with low latency—a critical dance for safety-critical systems.
BrakeBright’s evolution underscores a fundamental truth in hardware development: edge cases aren’t theoretical when lives are at stake. By embracing real-world chaos, leveraging median filtering, defeating harmonic sync, and adopting adaptive debouncing, this project offers a blueprint for resilient embedded design. As the developer puts it, "I’m still learning, still testing, still riding. Every update comes from real roads, real bugs, and a stubborn refusal to settle." For engineers building IoT devices that interact with the physical world, the lesson is clear: sometimes, innovation demands both technical rigor and a willingness to repurpose the unexpected.
Source: Original Blog Post