Flight PID control loop
This is a loop that adjusts the flying angle of the drone so it stays stable. It takes tilt input from the accelerameter and calculates the amount of correction needed.
Example code: http://coder-tronics.com/pid-tutorial-c-code-example-pt2/ http://code.activestate.com/recipes/577231-discrete-pid-controller/