Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: main.cpp
- Revision:
- 0:8508616aa661
- Child:
- 1:ae1120188730
- Child:
- 2:68f47ba7fe0a
diff -r 000000000000 -r 8508616aa661 main.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed May 02 03:53:27 2018 +0000
@@ -0,0 +1,50 @@
+#include "mbed.h"
+//Board:mbed LPC1768
+//Veriy GPS Lat/Long buffer Data from GNRMC sentence.If using Nema 0183 GPS, Change GNRMC to GPRMC
+//GPS Receiver: HolyBro
+//Wait until you get a good fix
+Serial gps(p9, p10); // TX, RX
+Serial pc(USBTX, USBRX); // TX, RX
+DigitalOut led1(LED1);
+
+char s[82];
+char y1,y2,y3,y4,y5,y6,y7,y8,y9;
+char x1,x2,x3,x4,x5,x6,x7,x8,x9,x10;
+char NS,WE;
+char GPSBuffer[1024];
+
+int main() {
+ pc.baud(9600);
+
+ // char gpsout[1024];
+ while (1) {
+ GPSBuffer[0] = '\0';
+ while (1) {
+ char c = gps.getc();
+ // char s[2];
+ s[0] = c;
+ s[1] = '\0';
+ strcat(GPSBuffer, s);
+ if (c == '\n') {
+ break;
+ }
+
+if ((GPSBuffer[1] == 'G') && (GPSBuffer[2] == 'N') && (GPSBuffer[3] == 'R') && (GPSBuffer[4] == 'M') && (GPSBuffer[5] == 'C'))//GNRMC Sentence
+ {
+ //Latitude
+ y1= GPSBuffer[19]; y2 = GPSBuffer[20]; //Degrees
+ y3= GPSBuffer[21]; y4 = GPSBuffer[22];y5= GPSBuffer[24]; y6 = GPSBuffer[25];y7= GPSBuffer[26]; y8 = GPSBuffer[27];y9= GPSBuffer[28]; //DEGMIN
+ NS = GPSBuffer[30];
+ //Longitude
+ x1= GPSBuffer[32]; x2= GPSBuffer[33]; x3= GPSBuffer[34];//Degrees
+ x4=GPSBuffer[35]; x5=GPSBuffer[36]; x6=GPSBuffer[38]; x7=GPSBuffer[39]; x8=GPSBuffer[40]; x9=GPSBuffer[41];x10=GPSBuffer[42];//DEGMIN
+ WE=GPSBuffer[44];
+ }
+ }
+
+ pc.printf("Latitude:%c%c:%c%c.%c%c%c%c%c %c",y1,y2,y3,y4,y5,y6,y7,y8,y9,NS); //Print latitude buffer data
+ pc.printf(" Longitude:%c%c%c:%c%c.%c%c%c%c%c %c\r\n",x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,WE); //Print Longitude buffer data
+
+ led1 = !led1;
+ }
+}