Another option:
x = 23.123456
x = x * 1000, now x = 23123.456
x = int x, now x = 12123
x = x/10, now x = 12.123
See it that helps. Maybe it's too simplistic an approach, makes sense in my mind anyway.
Data-wise, maybe you lose too much position detail that way, and it will put you 1000 feet from where you want to be or something.
i was trying how to get the average of 10 samples of the GPS reading but i think it i dont know how to convert it into code can you make out a code for me that takes 10 samples of GPS reading and compute me the direction
I was providing the example, you'll have to take the approach and adapt it to your specific code.
You may have to average in both Lat, Long, and Altitude for example.
I would think you'd need to perform the averaging here:
if (myGPS.decode(mygps.read())) {
// if so, set status led on
digitalWrite(13, HIGH);
// calculate direction to destination, relative to my own direction of movement
float lat = myGPS.gprmc_latitude();
float longi = myGPS.gprmc_longitude();
so make that section do 10 readings with the averaging as discussed:
float lat = 0;
float longi = 0;
for (int x = 0; x<10; x=x+1){
if (myGPS.decode(mygps.read())) {
// if so, set status led on
digitalWrite(13, HIGH);
// calculate direction to destination, relative to my own direction of movement
lat = lat+ myGPS.gprmc_latitude();
longi = longi + myGPS.gprmc_longitude();
}
lat = lat/10;
longi = longi/10;
}
// continue to the display code
The other reason your GPS says you are moving when you are not is so you can't "roll your own cruise missile"!
A military GPS won't do that.
Your smart phone gets better accuracy by using cell tower triangulation.
That falls down here 'coz I only get 1 cell tower.
If you want your trundle bot to move between waypoints you will have to live with a few metres of error.
The other thing I'm doing is using a digital compass, well 2 actually, one tilt compensated, one not.
The 2 digital compass' always agree on the heading, the GPS doesn't.