any reference site for the format code for tinygps.h to measure distance? or any codes for tinygps.h for measuring distance i'm just a beginner in learning arduino thank you

  • 1
    Do you know Pythagoras's theorem? – Majenko Feb 21 at 0:22

You don't use the tinygps.h library to measure distance. You use the tinygps.h library to get coordinates. Over short distances those coordinates (longitude and latitude) can be equated to x,y coordinates on a plane (over greater distance - hundreds or thousands of miles - it gets a whole lot more complex).

Two sets of x,y coordinates form a line. A line is one side of a right-angled triangle (the hypotenuse).

Pythagoras (remember him from math class? That rubbish you thought you'd never need? Well, now you do...) says that the square of the hypotenuse is equal to the sum of the squares of the other two sides.

You know the other two sides - they're just the difference between the two x coordinates and the two y coordinates.

We're not going to write the code for you, and Google is probably better at finding websites with example code on than we are.

| improve this answer | |
  • thanks man appreciate it :D by the way can i use this format code? float X = ((long2 - long1) * 24901 * cos(lat1)) / 360.0 float Y = ((lat2 - lat1) * 24860) / 360.0 float X2 = X * X; float Y2 = Y * Y; float Distance = sqrt(X2 + Y2); also how to define to my arduino that i set Lon1 Lat1 is equal to my desired gps coordinates should i used long or const or float sorry for many question – Reiniel Cirujano Antonio Feb 21 at 0:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.