very strange
The blocks are the same as I showed? And it would be useful to add what you sent and what you received. e.g. sent: m|0, received: xyz.
Is your serial monitor set to a good bit rate?
The blocks are the same and the bitrate is 38400
sending m 1 results in : ode
sending m 3 results in :
sending m 5 results in: e
However when choosing the manual mode the coordinates are being sent but it is weird it works fine for a little bit then starts bugging out updating randomly.
Ok.This should work.
void loop() {
if(SerialBT.available() > 0) {
String bt_tag = SerialBT.readStringUntil('|');
bt_data = SerialBT.readStringUntil('|').toInt();
if(bt_tag == "m") {
mode = bt_data;
Serial.println("mode" + String(bt_data));
} else if(bt_tag == "x" || bt_tag == "y") {
if(mode == 5) {
if(bt_tag == "x") {
xAxis = bt_data;
} else if(bt_tag =="y") {
yAxis = bt_data;
}
Serial.print("Coordinates: ");
Serial.print(xAxis);
Serial.print(",");
Serial.println(yAxis);
}
}
}
}
Thank you very much for your time and help. Can you tell me what was the problem with the first code you sent because i tried to fix it and couldnt?
Problem with controlling the number of bytes received. Here I added two byte delimiters and you can better control the receiving of data. You can add an unlimited number of tags here and send the given tag|data| in the system
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.