Étape 3: codage
Après que vous branchez votre câble USB utiliser ce code dans le logiciel arduino pour programmer votre GPS
#include
gpsSentenceInfoStruct info ; buff de char [256] ; public static unsigned char getComma (unsigned char num, const char * str) {unsigned char i, j = 0; int len=strlen(str) ; pour (j’ai = 0; j’ai < len ; j’ai ++) {si (str [i] == «, ») j ++; if(j == num) retourner i + 1;} return 0;} public static double getDoubleNumber (const char * s) {char buf [10]; unsigned char j’ai ; double rev ; j’ai = getComma (1 s); j’ai = i - 1; strncpy (buf s, i) ; buf [i] = 0 ; Rev=atof(BUF) ; retour rev ; } public static double getIntNumber (const char * s) {char buf [10]; unsigned char j’ai ; double rev ; j’ai = getComma (1 s); j’ai = i - 1; strncpy (buf, s, i); buf [i] = 0; rev=atoi(buf) ; retour rev;} void parseGPGGA (const char * GPGGAstr) {double latitude double longitude ; int tmp, heure, minute, seconde, num ; tmp = getComma (2, GPGGAstr); latitude = getDoubleNumber (& GPGGAstr[tmp]) ; tmp = getComma (4, GPGGAstr); longitude = getDoubleNumber (& GPGGAstr[tmp]) ; sprintf (buff , « https://www.google.com/maps/ latitude, longitude) ; %10.4F Serial.println(buff) ; } void setup() {/ / Mettez votre code de configuration ici, pour exécuter une fois : Serial.begin(115200) ; LGPS.powerOn() ; Serial.println ("LGPS allumez et en attendant...") ; Delay(3000) ; } void loop() {LGPS.getData (& info); parseGPGGA ((const char*) info. GPGGA) ; Delay(2000) ; }