Hi all!
I am trying to send lat and long values from my phone into my arduino via an hm-10.
The plan is to text something like this from my phone
47.234235,-78.235111
And the arduino stores two values
value1=47.234235
value2=-78.235111
but I am getting tripped up on formats char, char*, String, int coming from the hm-10 bluetooth module.
if you uncomment the line and then comment the line above it, the code runs perfectly-its just a problem when the values come from the hm-10.
Please help!
thank you,
Mike
#include <SoftwareSerial.h>
#include <string.h>
int bluetoothTx = 2; // TX-O pin of bluetooth mate, Arduino D2
int bluetoothRx = 3; // RX-I pin of bluetooth mate, Arduino D3
char *Lat, *Long;
SoftwareSerial bluetooth(bluetoothTx, bluetoothRx);
String readString;
void setup() {
Serial.begin(9600);
bluetooth.begin(115200);
delay(100);
bluetooth.println("U,9600,N");
bluetooth.begin(9600);
}
void loop() {
while(bluetooth.available())
{
delay(10);
char c = bluetooth.read();
if (c == ',') {
break;
}
readString += c;
}
if (readString.length() >0) {
char *test=readString;
//char *test="47.234235,-78.235111";
Lat = strtok(test,":");
Long = strtok(NULL,":");
Serial.print(Lat);
Serial.println("");
Serial.print(Long);
readString="";
}
}