The Tutorial Video :
In this video tutorial, I have used a
1.kk flight controller along with
2.An Arduino nano and
3.A GY-271 compass module (QMC5883l)
To add the feature of Direction Control using the initial direction as a reference and applying a proportional controller.
The first challenge was to accurately read the radio receiver's PWM signal for which I referred to
1.Joop Brokking's channel (the ultimate source to make drones using Arduino)channel: https://www.youtube.com/user/MacPuffdog
I also used an extra channel(chn5) to toggle between normal mode, YAW_hold mode and Altitude Hold mode.
Link for Code https://github.com/htgdokania/Drone_Direction_hold
I hope this helps out others and better version for the same is developed in future.
For Compass Refer: