Sunday, March 15, 2009

Here is the Modified Code with the changes I made in red.

/*
* SoftwareSerial Library provides Arduino an additional
* "Software" Serial Port
*/
#include

// SoftwareSerial TX & RX Pins
#define SoftrxPin 3
#define SofttxPin 2

int ledPin = 4;

//variables for parsing

char *parseptr;
char buffidx;
uint8_t hour, minute, second, year, month, date;
uint32_t latitude, longitude;
uint8_t groundspeed, trackangle;
char latdir, longdir;
char status;


/* Declare and Initialise SoftwareSerial Object
* - Setup the Software Serial Port
*/
SoftwareSerial mySerial = SoftwareSerial(SoftrxPin, SofttxPin);

// GPRMC byte variable from the GPS
byte GPRMC = 0;

// MessageLine - The Entire GPS Message Received
char messageLine[128];

void setup()
{
// Set the computer baud rate
Serial.begin(9600);

// Set the GPS BAUD RATE
mySerial.begin(4800);

// Receive GPS Serial Data on Digital Pin 2
pinMode(SoftrxPin, INPUT);
}

void loop()
{
uint32_t tmp;

GPRMC = mySerial.read();

if(GPRMC == '$')
{
// Clear out the previous GPS Message
for(int i =0; i< index =" 2;" gprmc =" mySerial.read();" parseptr =" messageLine+9;" tmp =" parsedecimal(parseptr);" parseptr =" strchr(parseptr," status =" parseptr[0];" latitude =" parsedecimal(parseptr);" parseptr =" strchr(parseptr," parseptr =" strchr(parseptr," latdir =" parseptr[0];" parseptr =" strchr(parseptr," longitude =" parsedecimal(parseptr);" parseptr =" strchr(parseptr," parseptr =" strchr(parseptr," longdir =" parseptr[0];" latdir ="=" latdir ="=" longdir ="=" longdir ="=" class="Apple-style-span" color="#FF0000">
Serial.println("ok, the real values the computer sees are:"); Serial.println(latitude); Serial.println(longitude);
if(latitude <= 32528210 && latitude >= 32528170){
Serial.println("latitude");
}
if(longitude <= 117143267 && longitude >= 117143227){
Serial.println("longitude");
Serial.println("it triggered!!!!");
digitalWrite(ledPin, HIGH);
delay(300);
digitalWrite(ledPin, LOW);
delay(100);
digitalWrite(ledPin, HIGH);
delay(300);
digitalWrite(ledPin, LOW);
delay(150);

}

//if (latitude != 0) {
// latitude *= 10000;
// parseptr = strchr(parseptr, '.')+1;
// latitude += parsedecimal(parseptr);
//}

}

for(int i = 0; i < d =" 0;"> '9') || (str[0] < '0')) return d; d *= 10; d += str[0] - '0'; str++; } return d; }

No comments:

Post a Comment