I have a prototype for this project. It’s an arduino nano 328p with a LSM303 compass and a gps module (neo 6m). I want to travel to a location using the gps and the compass. I have the angle between my location and the coordinates I want to go to. I also have my heading compared to true north. I want to solve for the angle between my coordinates and the ending coordinates compared to north.

For informed help, please read and follow the instructions in the "How to use this forum" post.

Post the code, using code tags, and explain what it should do, and what it does instead.

Nathaniel_:

I have the angle between my location and the coordinates I want to go to.

I assume the 'angle' you calculate is the desired heading. Subtract your current heading from the desired heading.

If the result is nearly zero:

just go straight

else

If the result is less than -180 degrees (or -Pi radians):

Turn Right

else

If the result is less than 0 degrees/radians:

Turn Left

else

If the result is less than 180 degrees (or Pi radians):

Turn Right

else // result is greater than or equal to 180 degrees (or Pi radians)

Turn Left

Nathaniel_:

I also have my heading compared to true north. I want to solve for the angle between my coordinates and the ending coordinates compared to north.

Is that not already the result of your calculation? You put in two latitude/longitude pairs and get a heading. The heading is relative to something, typically north.

I want to solve for the angle between my coordinates and the ending coordinates compared to north.

That is called the bearing angle. Calculate it using the formula on this web page.

GPS libraries like TinyGPS++ and NeoGPS have the bearing and distance functions built in.