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:
x=(-computedGyroAngleX-3.5)*10; y=(-computedGyroAngleY-2)*10; esc1.writeMicroseconds(rc_values[RC_CH1]+x-y); esc2.writeMicroseconds(rc_values[RC_CH1]+x+y); esc3.writeMicroseconds(rc_values[RC_CH1]-x-y); esc4.writeMicroseconds(rc_values[RC_CH1]-x+y);
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?