#include <SoftwareSerial.h>
#include <TinyGPS++.h>
TinyGPSPlus gps;                                        // the TinyGPS++ object. NOTE: USES UART
// SoftwareSerial gpsSerial(6, 7);                         // RX, TX
SoftwareSerial gpsSerial(2, 3);                         // RX, TX
double latitude = 0;                                    // latitude in degrees?
double longitude = 0;                                   // longitude in degrees?

#define LEDPIN 11

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);
  gpsSerial.begin(9600);

  pinMode(LEDPIN, OUTPUT);
  digitalWrite(LEDPIN, LOW);
  Serial.println("\nReady");
}

void loop() {
  // put your main code here, to run repeatedly:
  while (gpsSerial.available() > 0) {
    char c = gpsSerial.read();
  // while (Serial.available() > 0) {
  //   char c = Serial.read();
    Serial.write(c);
    if (gps.encode(c)) {
      if (gps.location.isValid()) {
        Serial.print("Lat: ");
        Serial.print(gps.location.lat());
        Serial.print(", Long: ");
        Serial.println(gps.location.lng());

        digitalWrite(LEDPIN, HIGH);
        delay(1000);
        digitalWrite(LEDPIN, LOW);
      }
    }
  }
}
