Hello Everyone ! PLease, How to properly code this, so that if i send it, the format will be like this:
<data,data,data> , so that when i receive those 3 data, i can easily separate them in different variables.
See the Serial Input Basics thread
I saw the separating of data and putting it in different variables >> in Serial Input Basics, that is for my receiving part,, but how about the Sending part where how to make my sensor 3 data to be send like this format: <data1,data2,data3> ?
Serial Input Basics - simple reliable ways to receive data.
If you want to send data in that format just do it like this
Serial.print('<');
Serial.print(data);
Serial.print(',');
Serial.print(data);
Serial.print('>');
...R
Robin, won’t that give problems if the code is repeated? He’ll get
<data,data,data><data,data,data><data,data,data><data,data,data>
If it runs multiple times.
Shouldnt he use
Serial.println(“>”);
For the last line if instead he wants
<data,data,data>
<data,data,data>
<data,data,data>
?
GreyArea:
Shouldnt he useSerial.println(“>”);
For the last line
That depends on the requirements of the receiving program. The code in the 3rd example in Serial Input Basics would not require the Serial.println() but it would not do any harm either.
...R
Fair enough, I was assuming serial monitor...
Big thanks for the HELP (Robin2, GreyArea, and UKHeliBob) !!! i got all my codes in linked
GreyArea: I put my println() in my receiver code, cause it didnt work in my sender code. Thanks anyway :))
Sender part :
HC12.print('<');
HC12.print(xValue);
HC12.print(',');
HC12.print(yValue);
HC12.print(',');
HC12.print(zValue);
HC12.print('>');
Receiver part:
void showParsedData() {
Serial.print(xValue);
Serial.print("\t");
Serial.print(yValue);
Serial.print("\t");
Serial.print(zValue);
Serial.println();
}
GreyArea:
Fair enough, I was assuming serial monitor...
You may be correct but I was assuming the use of the start- and end-markers was for the benefit of some receiving program that would make use of them.
...R