An Arduino self-balancing robot: working prototype

An Arduino self-balancing robot: working prototype

I spent some time reading on accelerometers, gyros, sensor fusion, PID, optimized PWM motor control. I tinkered with the components I have for a while and then procrastinated for even longer. Finally, I can say that I have a prototype of a self balancing bot that shows promise.

More fine-tuning is needed, and I plan to add a Bluetooth module to get PID controller data wirelessly, possibly to adjust the PID coefficients in real time and, hopefully to steer the bot remotely someday.

I plan to post a more detailed description with the code and schematics as I make progress. Here is my components list:

Planned additions:

I will likely replace the Li-Po battery with a 6AA battery pack and possibly a voltage booster (if necessary). A couple of reasons:

  • I already have these components from my line following project
  • The extra weight of the AA batteries at the top should actually help with the balancing
  • The Li-Po battery goes back to being a spare for my “Betamax” quadcopter, as originally intended. Now that the weather is better in Vancouver, I plan to get some more flight practice!
Tagged with: ,

28 Comments on “An Arduino self-balancing robot: working prototype

  1. Hi I found your site via Youtube whilst searching ‘Arduino balancing robot’.

    I am trying to build a robot like yours, I have had trouble sourcing rotary encoders so I would prefer to build a robot without them.

    I have the mpu6050, the arduino, the batterys and the L298N motor shield.

    The robot is made out of lego and is just needing programming ! Could I have a look at your code please becuase I am new to arduino !! (I have used Picaxe in the past)

    Thanks,
    Paul.

  2. Hi,
    I am doing the same work for my semester project, but i am new to arduino and also finding hard to implement PID control in arduino. Can you please give me the code and its associated libraries for balancing the robot.

  3. Thanks for validating my expectation that there was code and successful implementation of a self- balancing robot using the Invensense MPU-6050. I appreciate the video and links you provided.

  4. hello!
    congratulations for the great work. Magnificent!
    Also I’m trying to build a self balancing robot; but I’m having a lot of problems, please, could you send me the code for arduino be able to better understand how you put together all the sensors?
    Thank you very much

    Fede

  5. Hello I am very interested in building a balance robot but I lack the proper skills for now. Could you please e-mail the code. Thank you

  6. Hello .
    Have you added the encoders ? Do you plan to update this site with your progress?
    I am really .looking forward to see what you have done.

    • Hi Tyrone, yes, I will update the site as I make progress. Unfortunately, I have not had much time and desire to get back to this and finish it over the last few weeks. One reason is that I built a frame that is too heavy for the motors I have. I do not look fortward to rebuilding the frame and re-wiring everything once again, so naturally, I procrastinate…

      Thanks for your comment though – the fact that people come to this site and find it useful is the main reason to get me to finish these projects!

      Stan

      • Hello friend,
        your project is awesome, thank you very much. I am a university student, and as my final year project I selected to make this kind of thing. So I have no idea how to start it, could you please help me to do this.
        For my project I use MPU 6050 gyro and arduino mega board. I have no idea how to work with PID in here. can you send me the code, it is highly appreciated.
        Thank you.
        Email: [email protected]

  7. Hi Stan,
    Great post! I am currently also working on a balancing robot project (using MPU-6050) and your introduction was a great help. Will get time to finish the project soon? Although my balancing robot has been able to balance on the odd occasion, it is not at all perfect yet. Do you think that using an accelerometer-gryo and a PID is enough to get the robot balanced 100% of the time, or should I get some motor encoders?
    Thanks!
    Simon

  8. I’m doing similar project, could you please send me the code, I have some problems. I do not know what to do with imu sensor values, how to control motor pwms. Thanks 😉

  9. Hello, Stan

    Happy New years. I was wondering if you can send me the new update code for your balance robot with the encoders through email.
    Thank you.

  10. Hi I found your site via Youtube..
    i am trying to do the same project as yours but i am new to arduino. i already have all the component that you have stated above..could u please send to me the code and schematics for this project as soon as possible because i need to finish this project in this week. i really appreciate your kindness..

    here is my email : [email protected]
    thank you very much..

  11. Hi, I have a question about the reason why the batteries are place on top of the robot.
    Your reason is ‘The extra weight of the AA batteries at the top should actually help with the balancing.’, and doing that takes the center of gravity higher, right? That means if it falls or goes out of balance, the motors will have a harder time trying to get the robot back in balance again. I am working on the same project, with the same Gyro and stepper motors and I’ve placed my batteries as low as possible. Because than the center of gravity wil be much lower and it would be easier to get back in balance when the robot goes out of it.
    I am doing it wrong or are there more possibilities?
    Please respond, this is my year-project that I am working on, thank you.

  12. Hi Stan,

    I’ve got my self balancing robot using the same components, I’ve completed the wiring but now stuck on the coding part. Can I possibly get a copy of your code and libraries. That would be much appreciated. Great Job btw!

    my email: [email protected]

  13. Hello Stan. your project are awesome. I am a final year university’s student and do the same project for my final project. But i have a problem to do it. Can You please send me the code and the schematic for this project? I am really appreciate if you want to help me. Thanks. this is my email : [email protected]

  14. I am doing the same work for my semester project, but i am new to arduino and also finding hard to implement PID control in arduino. Can you please give me the code and its associated libraries for balancing the robot.
     Thanks. this is my email :

    [email protected]

  15. I have a similar configuration (MPU6050, UNO, l298n, 5V battery) but I cant stay balanced at all. some of it is backlash in the gearboxes. Some of it is that my code is way too simple.. “get X axis from MPU….if roll is 0 wheels reverse…pause… start over… ” I don’t see where you posted the code that drives your robot so hacks like me can see your solution and draw inspiration from it.

    Any chance you could share??

  16. Hi, I just watched the tutorial from EEEnthusiast (Arduino Accelerometer MPU-6050 Tutorial) and was wondering if you could help me with it. I’m working on a quadcopter and wanted to use the MPU to balance the unit. Do I need to use both accelerometer and gyroscope data to do that? Do you have an example I could use for it?

    Thanks,
    John

  17. Hi ,

    I’m new to PID control and I need it to work on my project . Can you please share your PID arduino code with me .

    Thanks

  18. I am doing the same work for my semester project, but i am new to arduino and also finding hard to implement PID control in arduino. Can you please give me the code and its associated libraries for balancing the robot.
    Thanks. this is my email :
    [email protected]

1 Pings/Trackbacks for "An Arduino self-balancing robot: working prototype"

Leave a Reply

Your email address will not be published. Required fields are marked *

*

This site uses Akismet to reduce spam. Learn how your comment data is processed.