Loading Abhiram Reddy Palle

→The labLab 01 / 10 · Embedded prototype

PrototypeMPU6050 · Microcontroller · LEDs · Buzzer

Motorcycle safety

Could a bike know when it's leaning too far?

The story, in 5 stages

  1. 01Problem
  2. 02Physical system
  3. 03Sensors
  4. 04Decision
  5. 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.

The signal chain
  1. 01→Raw readingsAccelerometer + gyroscope
  2. 02→AngleWorked out from the readings
  3. 03→ThresholdToo far? Compare.
  4. 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

MPU6050 · CH-01Simulated · 60 Hz
AX+0.00
AY+0.00
AZ+1.00
PEAK+0.00
N000000

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.

Lean angle · simulatedThreshold ±45°
-90°-45°0°45°90°

0°

LEDsBuzzer · off
  1. 01IdeaCould a bike know when it's leaning too far?
  2. 02WiringIMU, LEDs, buzzer, one microcontroller.
  3. 03CodeRaw readings → angle → threshold → warning.
  4. 05DebugCheck the axes. Check the maths. Check the axes again.
  5. 06Working prototypeIt worked. Eventually.

(07)The prototype

The prototype on the benchFig. 01
WiringFig. 02
Serial output, mid-debugFig. 03

(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]

Next on the bench — 02 / 10Sensor experimentMPU6050 orientation→Six axes of motion, turned into an angle you can see.