I have been messing with this for a while and can't make progress. I want to track forward on a set compass heading. If there is a variation from the heading I want to make a correction turn back toward the heading. I have made the compass to read with a +/- 5 degree tolerance. For setup I am using a deviation of 30 degrees, but will narrow it to 10 degrees once it is working.
$compass_setting = 150
$compass_setting2 = $compass_setting + 30
$compass_setting3 = $compass_setting - 30
if ($CompassHeading = $compass_setting)
if ($CompassHeading = $compass_setting3)
I have tried a number of variations but no luck.