Guys, I went through a lot of Arduino quadcopter codes, and observed the following steps in all of them:
- Sensor Initialization.
- Motor Initialization.
- Receiver Initialization.
- Motor Arming.
- PID Initialization.
- Sensor Value Update loop.
- Motor control loop using ESC pwm.
So, after getting sensor values from the IMU, we update the pwm signals to the ESC using our code.
Please refer :BlueCopter, Benripley arduino quadcopter, jeff rowberg mpu9250 and joop brokking arduino quad. for reference. They will help you get a better picture of what i am mentioning here.