Gyro gy-521

Im trying to build a drone ,my gyro works fine when i am trying to get values from serial port(esc calibrate code).When im trying to this(Flight controller) code led stays on (between 530-550 lines) position. I believe problem is about I2C bus communation but if it is how it works at other code?
Thank you :slightly_smiling_face:

YMFC-AL_Flight_controller.ino (40.3 KB)

esc_calibrate.ino (38.5 KB)