Introduction: Self Balancing Robot ArduinoUno/mpu6050/l298n

This is a two wheel self balancing robot

Step 1: Materials and Tools

The components are :

1) Sensor : 1 of Mpu6050 Gy521 Cost : 1$-2$ USD

2) Brain : 1 of Arduino Uno clone Cost 3$-4$ USD

3) Motor driver :1 of Module L298N Cost : 1-2$ USD

4) Batteries + batteries holder(prefer to have at least 1 with 3.5mm jack to power arduino uno) : can use AA, 9V or 18650 or phone power bank Cost : $5 to $20

The cheapest options are to use 2x 9V batteries or 8x AA batteries, I used 18650 because I have some around.

5) Frame: 3d printed with PLA weight = 300grams Cost : 5-10$ USD

6) Motor : 2 of TT gear motor 200rpm Cost : $4 to6$ USD

7) Ceramic Capacitor : 2 of value around 0.1mF

8) M3 screws or other mean to fit the board and motors

The frame structure is quite simple and can be constructed by other methods and material easily.

Total cost : About $25 to 50$ USD

Tools :

Soldering iron or other method of connecting wire and capacitor to motors

Step 2: Wire Connections

Wire the connections as shown in the picture

1) First Battery connect to 3.5 power jack of the arduino ( can be a 9V battery or 4x AA batteries or other as long as in the range of 6 to 12V).

2) MPU6050 Gy521 connect to the Arduino Uno (same pin for Arduino Nano) :

Vcc ------- 3.3V

GND ------- GND

SCL ------- A5

SDA------- A4


3) Second battery connect to L298N module :

Positive + ------- to +12V

Negavtive - ------- to GND

4) Second battery connect to Arduino Uno :

Negative - ------- to GND

5) L298N to Arduino Uno:

ENA ------- PIN10






6) Motors to L298N OUT1 and OUT2

7) 2 capacitor to two motor (solder or attach)

TO BE CONTINUE ...........

Step 3: Software :

Step 4: Comment and Troubleshoot

1)The heavy weight components (batteries in this case) should be place on top of the robot.

2)Using one power supply source for both arduino and motor will still work, however when motor draw too much current might cause the arduino turn on and off. Hence why two separated power supply were used.

3)The system can still work without the capacitors added to motor, however the motors can produce noise into the system, try without capacitors if you dont have them available.

4) When start the robot, make sure both motors are running in the same directions(either forward or backward, if you notice motors run in opposite direction, swap 1 of the motor pair wire from out1 or out2 on the L298N board.

5)The IMU mpu6050 is not perfectly position, when start the robot, observe and adjust so that when the robot in straight up balance position neither motor turns or only turn slightly. To adjust: physically tilt the IMU mpu6050 until reach the desire position, fit with tape or glue gun or other mean to fix the IMU mpu6050. Other option is to calibrate the software