JMP91:
Additionally, I also want to have a red LED turn on when the GPS does NOT have a fix, and a green LED turn on when it DOES have a fix. Any ideas for what function to use for that?
Well honestly I'd like to see the whole program again because like michinyon I have my doubts you're doing everything 100% correctly, but if you're wondering how to do the Red/Green LED fix I was taking a break from my work and did this:
const byte GREEN_LED_PIN = 99;
const byte RED_LED_PIN = 99;
const long TIMEOUT_INTERVAL = 10000L;
unsigned long lastUpdated = 0;
void setup() {
pinMode(GREEN_LED_PIN, OUTPUT);
pinMode(RED_LED_PIN, OUTPUT);
// Turn on the RED LED to indicate we have no fix yet
digitalWrite(RED_LED_PIN, HIGH);
digitalWrite(GREEN_LED_PIN, LOW);
[...]
}
void loop() {
boolean isUpdated = false;
// Read data from the serial port and all that good stuff here...
[...]
if (gps.location.isUpdated()) {
[...]
isUpdated = true;
}
if (gps.speed.isUpdated()) }
[...]
isUpdated = true;
}
[...]
// Do we need to log data to the SD card?
if (isUpdated) {
// Handle the LED stuff first
lastUpdated = millis(); // Keep track of last good update
digitalWrite(GREEN_LED_PIN, HIGH); // Green LED means we've got a fix
digitalWrite(RED_LED_PIN, LOW); // Turn off the "no fix" LED
// Write to SD card here
[...]
}
else {
// Been too long since we last got good data?
if (millis() - lastUpdated > TIMEOUT_INTERVAL) {
// Yes. Indicate our displeasure
digitalWrite(GREEN_LED_PIN, LOW);
digitalWrite(RED_LED_PIN, HIGH);
}
}
}
There is quite a bit omitted but I hope you get the idea.
Regards,
Brad
KF7FER