Advertisement
Guest User

edited arduino

a guest
Oct 22nd, 2013
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. #include <SoftwareSerial.h>
  2.  
  3. /*
  4. Example of GPS MTK library.
  5. Code by Jordi Munoz and Jose Julio. DIYDrones.com
  6.  
  7. Works with Ardupilot Mega Hardware (GPS on Serial Port1)
  8. and with standard ATMega168 and ATMega328 on Serial Port 0
  9.  
  10. edited for GPS attached to softserial, computer hard serial
  11. */
  12.  
  13. #include <GPS_MTK.h> // UBLOX GPS Library
  14.  
  15. const int enable_pin = 9; // Enable needs to be High for GPS to operate, according to manual
  16.  
  17. void setup()
  18. {
  19. pinMode(enable_pin,OUTPUT);
  20. digitalWrite(enable_pin,HIGH);
  21. Serial.begin(38400);
  22. Serial.println("GPS MTK library test");
  23. GPS.Init(); // GPS Initialization
  24. delay(1000);
  25. }
  26. void loop()
  27. {
  28. GPS.Read();
  29.  
  30. Serial.print("GPS:");
  31. Serial.print(" Lat:");
  32. Serial.print(GPS.Lattitude);
  33. Serial.print(" Lon:");
  34. Serial.print(GPS.Longitude);
  35. Serial.print(" Alt:");
  36. Serial.print((float)GPS.Altitude/100.0);
  37. Serial.print(" GSP:");
  38. Serial.print((float)GPS.Ground_Speed/100.0);
  39. Serial.print(" COG:");
  40. Serial.print(GPS.Ground_Course/1000000);
  41. Serial.print(" SAT:");
  42. Serial.print((int)GPS.NumSats);
  43. Serial.print(" FIX:");
  44. Serial.print((int)GPS.Fix);
  45. Serial.print(" TIM:");
  46. Serial.print(GPS.Time);
  47. Serial.println();
  48.  
  49. delay(1000);
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement