This guide shows how to use the NEO-6M GPS module with the Arduino to get GPS data. GPS stands for Global Positioning System and can be used to determine position, time, and speed if you’re travelling.
#include <TinyGPS++.h>
#include <SoftwareSerial.h>
static const int RXPin = 4, TXPin = 3;
static const uint32_t GPSBaud = 9600;
// The TinyGPS++ object
TinyGPSPlus gps;
// The serial connection to the GPS device
SoftwareSerial GPS(RXPin, TXPin);
void setup(){
Serial.begin(9600);
GPS.begin(GPSBaud);
}
void loop(){
while (GPS.available() > 0){
gps.encode(GPS.read());
if (gps.location.isUpdated()){
Serial.print("Latitude= ");
Serial.print(gps.location.lat(), 6);
Serial.print(" Longitude= ");
Serial.println(gps.location.lng(), 6);
}
}
}
0 Comments