gps guided car

hi :) i wanna set a track to a robot car using GPS of my mobile So,, i make an app by app inventor which take the longitude and latitude of my current location & my destination and do some calculations so that i can get the distance between the two places and after that it sends the distance to the arduino using "call BluetoothClient.send text" in app inventor the problem is that i can't convert the received distance to a float number so that i can use it in my code i made a sample code just to explain what i mean

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  if(Serial.available()>0)
  {
  float a=Serial.read();
  Serial.println(a);
}
}

the distance in the app was 2.01413 and in tha serial monitor was :

50.00 46.00 48.00 49.00 52.00 49.00 51.00

which is the ascii code of 2.01413 how could i convert it to be float " 2.01413" ??

You better have a big track, since GPS is only good to 10 meters or so.

Gather all the characters into a string and convert it with strtod().

Unfortunately i can't know how to put all the characters into one string i used String distance=Serial.read(); but there's an error

no known conversion for argument 1 from 'int' to 'const

Serial.read( ) reads on character. You need to collect all the characters in your number and then get the float value out of that.

You need to collect all the characters in your number and then get the float value out of that.

i don’t know how to do that …

void setup()
{
  Serial.begin(9600);
}

void loop()
{
  if(Serial.available())
  {
    float a = Serial.parseFloat();
    Serial.println(a);
  }
}
void setup()
{
  Serial.begin(9600);
}

void loop()
{
  if(Serial.available())
  {
    float a = Serial.parseFloat();
    Serial.println(a);
  }
}

it works but it prints only the first four digit
so if the sent distance is 1.45851
it prints 1.45

    Serial.println(a);

default is two decimals, try:

    Serial.println(a , 6);

it works perfectly thank you :)