A fully autonomous self-balancing robot designed using an MPU6050 IMU, PID control, and DC motors driven by an H-Bridge. This project demonstrates embedded real-time control, sensor fusion, and actuator feedback, showcasing a classic implementation of a 2-wheeled inverted pendulum using affordable components and an Arduino.
This robot maintains its vertical balance by continuously reading its tilt angle via the MPU6050's DMP (Digital Motion Processor) and adjusting motor speeds with a PID controller. It also includes Bluetooth-based commands that allow the robot to move forward or backward while staying balanced.
- 🎯 Real-time PID control (10ms loop)
- 🧭 Tilt estimation using MPU6050 DMP
- ⚙️ Dual DC motor control with L298N H-Bridge
- 🔧 Tunable PID constants
- ⚖️ Dynamic setpoint adjustment for movement
Component | Quantity | Notes |
---|---|---|
Arduino UNO | 1 | Main microcontroller board |
MPU6050 IMU | 1 | 6-axis accelerometer + gyroscope |
L298N Motor Driver | 1 | Dual H-Bridge for controlling 2 DC motors |
DC Gear Motors (12V) | 2 | Connected to wheels |
Battery Pack (7.4–12V) | 1 | Power source |
Misc. parts | - | Wires, resistors, chassis, etc. |
[MPU6050] --> [DMP + YPR Angle] --> [PID Controller] --> [Motor Output]
- MPU6050 DMP is initialized with calibration offsets.
- Interrupts are set for new sensor data.
- PID controller is initialized with
Kp
,Ki
,Kd
.
- When new data is available, pitch is extracted.
- PID computes motor correction.
- Motors are driven with PWM.
double Kp = 70;
double Ki = 250;
double Kd = 3;
Tune according to your hardware configuration using trial-and-error or Ziegler–Nichols method.
Self-Balancing.Robot.mp4
Josh Sebastián López Murcia