Libraries \ NMEA

Reference for Wiring version 1.0 Build 0100+ If you have a previous version, use the reference included with your software. If see any errors or have any comments, let us know.

Class

NMEA

Name

gprmc_course()

Examples
#include <nmea.h>

NMEA gps(GPRMC);  // GPS data connection to GPRMC sentence type
float d;          // relative direction to destination

// destination coordinates in degrees-decimal
float dest_latitude = 48.858342;
float dest_longitude = 2.294522;

void setup() {
  Serial1.begin(4800);
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
}

void loop() {
  if (Serial1.available() > 0 ) {
    // read incoming character from GPS
    char c = Serial1.read();

    // check if the character completes a valid GPS sentence
    if (gps.decode(c)) {
      // check if GPS positioning was active
      if (gps.gprmc_status() == 'A') {
        // calculate relative direction to destination
        d = gps.gprmc_course_to(dest_latitude, dest_longitude) - gps.gprmc_course();
        if (d < 0) { d += 360; }
        if (d > 180) { d -= 360; }
        // set LEDs accordingly
        if (d < 5) {
          digitalWrite(8, HIGH);
        } else {
          digitalWrite(8, LOW);
        }
        if (d > -5) {
          digitalWrite(9, HIGH);
        } else {
          digitalWrite(9, LOW);
        }
      }
    }
  }
}
Description Returns direction of movement in degrees. North is 0o, East is 90o, South is 180o, West is 270o. For example, if gprmc_course() returns 227.13, then you are moving roughly in South-West direction.
Syntax
gprmc_course()
Returns float
Usage Application
Updated on July 07, 2011 11:11:09pm PDT

Creative Commons License