Self-Balancing PID Robot
Complementary filter & deadzone-compensated PID motor loop.

Pipeline & core implementation
float computeMotorPwm(float angleErr, float dt) {
integral += angleErr * dt;
float deriv = (angleErr - prevErr) / dt;
prevErr = angleErr;
return kp * angleErr + ki * integral + kd * deriv;
}Sensor fusion & 200 Hz timing
An accelerometer alone reacts cleanly at rest but picks up motor vibration, whereas integrating raw gyroscope rates drifts within seconds. Fusing 98% integrated MPU6050 gyro angle with 2% accelerometer tilt over 400 kHz I2C keeps pitch estimation responsive at a fixed 5 ms control tick.
Fixing gearmotor deadzone wobble
Small yellow DC gearmotors driven through an L298N H-bridge barely turn below PWM ~45, forcing a pure PID controller to hunt back and forth around vertical (limit-cycle oscillation). Mapping non-zero PID sign commands past the static friction threshold locked upright balance.
Two-tier Fusion 360 chassis
Modeled the full stacked frame in Fusion 360 to balance battery mass high enough for a slower natural pendulum period—giving the 200 Hz Nano loop plenty of recovery margin.
Measured benchmarks
Project status & checklist
● Completed- Two-tier stacked Fusion 360 3D CAD assembly & BOM
- 400 kHz I2C MPU6050 complementary filter & 200 Hz PID loop
- L298N static-friction deadzone compensation eliminating upright wobble
All planned milestones complete.