
This website showcases the development, implementation, and final results of our autonomous two-wheeled balancing robot.
🌐 View on GitHubWelcome to the official project page for our Self-Balancing Robot. This website showcases the development, implementation, and final results of our autonomous two-wheeled balancing robot. Built as part of our control systems course (ENEE/ENME 461), this project merges hardware, software, and control theory into a compact, responsive platform.
Inspired by the classic inverted pendulum problem, our robot demonstrates real-time balance using sensor feedback and PID control. It uses an ESP32 microcontroller, an MPU6050 IMU, and two DC gear motors controlled via a dual H-bridge. The challenge? Keep the robot upright on just two wheels—like a miniature Segway.
Our robot features:
Wiring Note: We routed power from the 12V battery through buck converters to deliver clean 5V and 3.3V for logic and sensor components. All grounds from the Arduino, H-bridge, IMU, and buck converters are tied together to form a common ground reference. Motor power lines run directly from the battery to the L298N to handle current draw, while logic control pins are connected from the Arduino to the H-bridge via digital pins. I²C lines from the MPU6050 are connected to A4 and A5, with pull-up resistors handled internally. Each connection was tested using a multimeter for continuity, and critical joints were soldered and insulated with shrink wrap for durability.
All components were selected based on torque calculations and center of mass optimization. The wheels are 5 inches in diameter, offering a balance between responsiveness and ground clearance.
The IMU is mounted close to the motors to reduce sensor lag and noise, while the battery is positioned low in the chassis to help with overall center of mass and balancing. The buck converters provide stable 5V and 3.3V rails from the main 12V battery, which also directly powers the motors and is safe for the Arduino’s VIN input (which tolerates up to 12V). Even with a 2V drop across the motors, our logic power is regulated and isolated from load variations.
We routed power from the 12V battery through buck converters to deliver clean 5V and 3.3V for logic and sensor components. All grounds from the Arduino, H-bridge, IMU, and buck converters are tied together to form a common ground reference. Motor power lines run directly from the battery to the L298N to handle current draw, while logic control pins are connected from the Arduino to the H-bridge via digital pins. I²C lines from the MPU6050 are connected to A4 and A5, with pull-up resistors handled internally. Each connection was tested using a multimeter for continuity, and critical joints were soldered and insulated with shrink wrap for durability.
The chassis was designed using Fusion360 and printed with PLA. The base houses the motors, driver, and battery. A custom bracket mounts the IMU at wheel axle level to reduce measurement noise. Zip ties and shrink tubing were used to secure and organize wires.

We implemented a PD (Proportional-Derivative) control loop in C++ on the ESP32. Real-time pitch angle is read from the MPU6050, processed, and used to drive the motors with appropriate speed and direction. The system runs a loop every few milliseconds and includes a safety cutoff if the robot tilts beyond ±25°.
Key features:
Initial tuning was done using only the proportional term (Kp). We observed oscillations and instability at high Kp values. Adding the derivative term (Kd) improved stability and response time.
Final stable tuning:
We used MS Excel’s Data Streamer to collect and visualize data from serial output, allowing analysis of angle, error, and motor input over time.
Our robot successfully balances under mild disturbances and showcases dynamic feedback in action. It reacts quickly, stabilizes after nudges, and remains upright unless excessive weight or tilt is applied.
Refer to the shopping list document for exact components. Major items include:

| Function | Component | Arduino Pin | Direction | Notes |
|---|---|---|---|---|
| Motor A DIR 1 | H-Bridge INA1 | D7 | Output | Sets forward/reverse |
| Motor A DIR 2 | H-Bridge INB1 | D8 | Output | |
| Motor A PWM | H-Bridge PWM1 | D5 | PWM Output | |
| Motor B DIR 1 | H-Bridge INA2 | D9 | Output | |
| Motor B DIR 2 | H-Bridge INB2 | D10 | Output | |
| Motor B PWM | H-Bridge PWM2 | D6 | PWM Output | |
| I²C SDA | MPU6050 | A4 | I²C | Connects to MPU6050 SDA |
| I²C SCL | MPU6050 | A5 | I²C | Connects to MPU6050 SCL |
| 5V Logic Power | H-Bridge / IMU | - | Power | From 5V buck converter |
| GND | All Devices | - | Ground | Common ground for all |
| VIN | 9V Battery | VIN | Power Input | Powers Arduino Uno |
Week 1:
Week 2:
Week 3:
This project was a successful application of control theory, hardware integration, and real-time feedback systems. Despite minor hardware limitations (motor torque, wheel grip), we achieved a reliable self-balancing robot that visually and functionally reflects our knowledge in embedded control.