PrototypeMPU6050 · Microcontroller · LEDs · Buzzer
Motorcycle safety
Could a bike know when it's leaning too far?
The story, in 5 stages
- 01Problem
- 02Physical system
- 03Sensors
- 04Decision
- 05Prototype
⚠ An experimental safety concept — not a production safety system.Prototype — do not ride on it
(01)What was the problem?
A motorcycle doesn't tell you how far it's leaning — you find out from the road. Could a small board on the bike notice when a lean is getting extreme, and say so while there's still time to react?
(02)What did I build?
A bench prototype: an MPU6050 motion sensor, one microcontroller, LEDs and a buzzer. It reads orientation, works out the lean angle, and warns when the angle gets extreme.
- P-01SensesMPU6050
- P-02DecidesMicrocontroller
- P-03ShowsLEDs
- P-04ShoutsBuzzer
(03)How does it work?
Raw readings → angle → threshold → warning. Four steps, and every one of them had a way to go wrong.
- 01→Raw readingsAccelerometer + gyroscope
- 02→AngleWorked out from the readings
- 03→ThresholdToo far? Compare.
- 04■WarningLEDs + buzzer
(04)The sensor
The MPU6050 is a 3-axis gyroscope and a 3-axis accelerometer on one chip, talking I²C. The accelerometer knows which way gravity points; the gyroscope knows how fast the board is turning.
Datasheet · P-043-axis gyroscope + 3-axis accelerometer · I²C
Move your cursor. This is roughly how an accelerometer sees motion — I just swapped the sensor for your mouse.
(05)The data
Six numbers, many times a second: acceleration along X, Y and Z, and rotation around each axis. On their own they're noise. The lean angle is what you work out from them.
- Accel
- AX
- Accel
- AY
- Accel
- AZ
- Gyro
- GX
- Gyro
- GY
- Gyro
- GZ
Six channels in. One number out: the lean angle.
(06)The decision
Compare the angle with a threshold. Past it, the LEDs light and the buzzer sounds. Below it, the board stays quiet — a warning that cries wolf gets ignored.
0°
- 01IdeaCould a bike know when it's leaning too far?
- 02WiringIMU, LEDs, buzzer, one microcontroller.
- 03CodeRaw readings → angle → threshold → warning.
- 05DebugCheck the axes. Check the maths. Check the axes again.
- 06Working prototypeIt worked. Eventually.
(07)The prototype
(08) TestingThe sensor had other plans
−135°
Why is it reading −135°?
The sensor had other plans. Check the axes. Check the maths. Check the axes again. Orientation bugs rarely look like bugs — they look like a perfectly confident, perfectly wrong number.
Axes → maths → axes again → fixed.
[ADD — how you tested it, and what fixed it](09)Where it stands
It worked. Eventually.
A working bench prototype. It worked. Eventually. It's an experimental safety concept — not a production safety system, and not something to trust on a real road.
[ADD — where it stands now: parked, next version, or on a bike?]
(10)On my bench
What I actually did with it
- 01MPU6050, a microcontroller, LEDs and a buzzer
- 02Lean angle worked out from orientation readings
- 03A threshold that triggers the LEDs and the buzzer
- 04The −135° bug — found, fixed
[ADD — photos, wiring, which microcontroller, the code, how you tested it]
Related on the bench