Introduction: Self Balancing Robot
Are self-balancing robots old? No! not at all for all the enthusiast available out there.It is amazing to see these bot struggling to balance. Actually, I have already made this bot once but that was without PID. This version has a PID embedded in it with less coding complexity.
Part List
1. DC Motors or better be servo motors or better be stepper motors
2. L293D
3. 0.1uF X 4 Ceramic Capacitors
4. Bluetooth Module HC05
5. 0.1 uF Ceramic Capacitor
6. Hot Glue
7. Arduino (Any version of your hobby box)
8. GY-521 Gyro+Accelerometer
Step 1: What Is This Actually ?
I 'll be straight. You have a stick. You are holding it vertically on your palm. It starts falling on one side and you move your hand to that direction to maintain its balance. This is done to maintain the center of gravity within the vertical line.The top and bottom of the stick are the limit points. If COG lies outside the line joining this line then it will lose balance. To maintain its balance it what we are gonna do.
Step 2: Building
I have used a breadboard to assemble the circuitry. You are free to choose yours. I am using ceramic capacitors to filter out the noise from DC Motors. You must attach two ceramic capacitors across the 5v and 36V terminals of L293D for more noise filter. This is necessary as the noise may turn off your MPU6050 or HC05 or may even reset your Arduino.
I have used HC05 to upload my sketches wirelessly. Serial Monitor can also be accessed wirelessly.
If you are using servos having low RPM then use larger wheels. If you are using DC motors with high RPM then you can use smaller wheels.
Step 3: Make Your Robot Frame
Apply Glue to bot motors. Then use the Acrylic sheet to join them. I have painted them white.
Step 4: Add All the Electronics.
Mount the weight on top if possible. Mount your Gyro along the axis to motors. This is done because linear acceleration is least at that point.
Step 5: PID Tuning.
1. Set P = 0, I = 0, D = 0.
2. The increase P until your bot starts oscillating. It may oscillate wildly or even swiftly. It should be between these two.
3. Increase D to reduce the oscillations.
4. Increase I to increase its response. Higher is the I value, quicker is the response time when it's out of balance. Larger the I value, less is the inclination limit.
Step 6: Source Code
Working of the Bot
Do follow my blog guys Visit it here www.hellocodings.com
It appears that Github script and Instructable.com are rivals. Some spaces are missing in the code. Please take care of it.
The only reason why my bot is 98% stable and not 99% is because of backlash error. 100% is not possible since not balance bot can stand still. For a better stability use gripped rubber wheels. Mine had plane surface rubber wheels. Gripped with cut type wheel will increase your stability since stability depends not only on an algorithm or MPU readings but also on better physical characteristics of the robot.
Here is the link if you want for formatted code Code

Participated in the
Arduino Contest 2017

Participated in the
Wheels Contest 2017
10 Comments
4 years ago
Где схема подключения?
Question 5 years ago
Hello first off awesome project; I was wondering if it is at all possible to adjust your angles from completely horizontal all the way up to vertical so a full 90 degrees via a rotary dial. My idea is to use it in an RC car so that I can do a wheelie at the turn of a dial and remain in that position until I turn it back down, sorry about the complicated question but thanks for any help I may get
Answer 5 years ago
Yes you can use it though you must use a high torque motor.
Question 5 years ago
where is the wiring diagram?
5 years ago
Hello Suman,
Greetings!
Firstly Congratulations on this wonderful project, and I wish to make one myself.
I want to know, can Arduino Nano be used for this? If so, need any changes be made to the coding?
Also, what's the use of the Bluetooth Module? I went through your blogpost too, and noticed that perhaps you hadn't included Bluetooth Module while listing down for "self balancing bot without PID".
Lastly, from your write ups i believe you are using the Capacitors as Filters. Where & how to use them?
Thank You
Reply 5 years ago
Hello,
Indeed you can use Arduino Nano. However, a small change is required. Nano outputs 5v whereas Bluetooth Module uses 3.3v logic level. So TX of Nano would go to a voltage divider. The Voltage divider will divide the voltage and provide 3.3v logic for RX of Bluetooth. TX of Bluetooth can straight go RX of Nano as TX of Bluetooth will be at 3.3v level which is acceptable for Nano.
The Bluetooth I used is HC 05.
If you can get a 5V logic level Bluetooth, no divider is required. This is the reason I used Pro Mini.
I have used Bluetooth module to wirelessly upload the code from Arduino IDE (PC or Mac) to my bot without messing with wires. I can even use it as a wireless serial monitor.
Capacitors are used here to provide a delay output. Whenever HC05 is connected to a device, it's state pin will go high otherwise low. So when my PC is connected to HC05 to upload code, the pin goes high which in turn charges the capacitor. This capacitor then discharges to reset the Arduino.
Reset is required here to upload the code to Arduino,
State pin of HC05 will go to one end of Capacitor. The other end of the capacitor will go to the reset pin of Arduino.
Regards
Question 5 years ago
Hello Suman,
Greetings!
Firstly Congratulations on this wonderful project, and I wish to make one myself.
I want to know, can Arduino Nano be used for this? If so, need any changes be made to the coding?
Also, what's the use of the Bluetooth Module? I went through your blogpost too, and noticed that perhaps you hadn't included Bluetooth Module while listing down for "self balancing bot without PID".
Lastly, from your write ups i believe you are using the Capacitors as Filters. Where & how to use them?
Thank You
5 years ago
I like the instructable and was going to try it but the link to the source code took me to another blog but no source code. Could you make the source available It looks like you are very successful with this bot.
Reply 5 years ago
Well, I have checked the link it has the source code.
Reply 5 years ago
Awesome thanks so much.