I was working on an Arduino quadcopter project. I setup all my hardware and was having balancing problems with my software end. I am using an MPU-6050 gyro and accelerometer. I have calculated the angle of the quad in relation to the ground and was trying to implement these values by adjusting the output values to each of the four motors.

Here is some of my code:


If the quad is leaning forward I increase the power at the front of the quad and reduce it at the back. I do the same for the y axis. But I run into problems when I test out the quad. It flips over to the side or forward. How would I fix this?

  • Hello and welcome. Could you please edit in another line break near your code section... to make code formatting work (I cannot do the edit due to the six-character rule).
    – Ghanima
    May 1, 2017 at 21:29
  • Such task is usually done by PID regulator (library) and to save you a lots of time by trying to tune it correctly also by PID Autotune library
    – KIIV
    May 3, 2017 at 16:56

1 Answer 1


That was happening with me too. Check if the weight distribution of the drone is perfect. Lets say if the battery is placed a little more to one side of the frame than the other side, your drone will try to hover from the other side. The center of gravity should be taken care of when the drone is not balancing properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.