Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <SoftwareSerial.h>
- /*
- Example of GPS MTK library.
- Code by Jordi Munoz and Jose Julio. DIYDrones.com
- Works with Ardupilot Mega Hardware (GPS on Serial Port1)
- and with standard ATMega168 and ATMega328 on Serial Port 0
- edited for GPS attached to softserial, computer hard serial
- */
- #include <GPS_MTK.h> // UBLOX GPS Library
- const int enable_pin = 9; // Enable needs to be High for GPS to operate, according to manual
- void setup()
- {
- pinMode(enable_pin,OUTPUT);
- digitalWrite(enable_pin,HIGH);
- Serial.begin(38400);
- Serial.println("GPS MTK library test");
- GPS.Init(); // GPS Initialization
- delay(1000);
- }
- void loop()
- {
- GPS.Read();
- Serial.print("GPS:");
- Serial.print(" Lat:");
- Serial.print(GPS.Lattitude);
- Serial.print(" Lon:");
- Serial.print(GPS.Longitude);
- Serial.print(" Alt:");
- Serial.print((float)GPS.Altitude/100.0);
- Serial.print(" GSP:");
- Serial.print((float)GPS.Ground_Speed/100.0);
- Serial.print(" COG:");
- Serial.print(GPS.Ground_Course/1000000);
- Serial.print(" SAT:");
- Serial.print((int)GPS.NumSats);
- Serial.print(" FIX:");
- Serial.print((int)GPS.Fix);
- Serial.print(" TIM:");
- Serial.print(GPS.Time);
- Serial.println();
- delay(1000);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement