Bonjour à toutes et à tous !
Voila je suis en 1ère et je fais mon TPE et je bloque sur une partie !
En gros j'ai programmé un gps, donc je récupère une trame GPGGA ,
en général de cette forme : "$GPGGA,163650,00,4830.7145,N,00244.1198,W,0,00,0.0,,M,M,,"
Je veux juste obtenir la parti : 4830.7145,N et ensuite 00244.1198,W
Jai testé plusieurs code :
String tab1[58]="$GPGGA,163650,00,4830.7145,N,00244.1198,W,0,00,0.0,,M,M,,";
int tab[15];
char compt=0;
int i;
char tab1[58]="$GPGGA,163650,00,4830.7145,N,00244.1198,W,0,00,0.0,,M,M,,";
char compt=0;
char valcalcul;
int j=0;
char tab2[80];
int i;
void setup()
{
Serial.begin(9600);
}
void loop()
{
for( i=0;i!=58;i++)
{
if ( tab1*==',')*
-
{*
-
compt++;*
-
}*
-
if (compt==3)*
-
{*
-
tab2[j]=tab1[i+1];*
-
j++;*
-
}*
-
if (compt==4)*
-
{*
-
tab2[j]=tab1[i+1];*
-
j++;*
-
}*
-
for (j=0;sizeof(tab2[j]);j++)*
-
{*
-
valcalcul=tab2[j];*
-
Serial.write(valcalcul);*
-
}*
-
delay(1000); *
-
}*
}
Et ensuite celui est celui que quelqu'un ma conseillé :
String tab1[58]="$GPGGA,163650,00,4830.7145,N,00244.1198,W,0,00,0.0,,M,M,,";
int tab[15];
char compt=0;
int i;
void setup()
{
- Serial.begin(9600);*
}
void loop()
{ - for ( i=0;i!=58;i++)*
- {*
_ if ( tab1*=',')_
_ {_
_ tab[compt]=i;_
_ compt++;_
_ }_
_ }_
String tab2[100];
int j=0 ;
for (int i=tab[1];i< tab[2];i++,j++)
_ {_
_ tab2[j]=tab1;
}
for (j=0;sizeof(tab2[j]);j++)
{
Serial.write(tab2[j]);
}
}*
*Voila j'espere que vous pourrez me répondre . En attente de vos réponses et si vous en avez ! *_