I have uploaded my program to my arduino mega 2560,done all the connections but nothing happening.
The only thing that is seen in the serial monitor is the void setup()
Serial.println("The GPS Receeved Signal");
Nothing happens after this.
Here is my code:
#include <TinyGPS.h>
//long lat,lon; // create variable for latitude and longitude object
float lat,lon;
TinyGPS gps; // create gps object
void setup(){
Serial.begin(57600); // connect serial
Serial.println("The GPS Received Signal:");
Serial1.begin(115200); // connect gps sensor
}
void loop(){
while(Serial1.available()){ // check for gps data
if(gps.encode(Serial1.read()))// encode gps data
{
gps.f_get_position(&lat,&lon); // get latitude and longitude
Serial.print("Position: ");
//Latitude
Serial.print("Latitude: ");
Serial.print(lat,6);
Serial.print(",");
//Longitude
Serial.print("Longitude: ");
Serial.println(lon,6);
}
}
}