Arduino Self-Balancing Robot

Hello, everyone!

In this instructable, I’ll show you how to build a small self-balancing robot that can move around avoiding obstacles. This is a tiny robot measuring 4 inches wide and 4 inches tall and is based on the Arduino Pro Mini development board and the MPU6050 accelerometer-gyroscope module.

In the steps that follow, we will see how to interface the MPU6050 with Arduino, how to measure the angle of inclination of the robot, how to use PID to make the robot stay balanced. An ultrasonic rangefinder is also added to the robot which prevents it from banging into obstacles as it wanders around.

Diagram:

Components:

1) BO Gear Motor : https://roboman.in/mj5r
2) Smart Robot Car Tyres Wheels : https://roboman.in/ro6c
3) L298N 2A Based Motor Driver Module: https://roboman.in/s9hs
4) Arduino Nano: https://roboman.in/59h4
5) Arduino Nano Type C : https://roboman.in/xkfu
6) MPU-6050 3-Axis Accelerometer and Gyro Sensor : https://roboman.in/2ctr
7) 18650X2 Double Battery Cell Holder : https://roboman.in/pgdz
8) 18650 Lithium Battery 2500mah 3C :https://roboman.in/utwc
8) 18650 Lithium Battery 2600mah 3C :https://roboman.in/mmab
8) 18650 Lithium Battery 2200mah 1C :https://roboman.in/70b5
8) 18650 Lithium Battery 2000mah 1C :https://roboman.in/7em9
8) 18650 Lithium Battery 1800mah 1C :https://roboman.in/ywss

Library File:

Code: