hello everyone,
i need to split data from this serial input data..
213,342,234p
23,343,343p
ending character for this data is letter p...
so for i tried to split using string and sub string option...its working fine with this example 213,342,234p,
but for this 23,343,343p...its not acting properly..i tried to do delimeter type..but i dnt have much info abt it... i have upload my code...
char recievedChar;
String temperature;
String gas;
String breaks;
String readString;
int value;
void setup()
{
Serial.begin(9600);
}
void loop()
{
test();
}
void test() {
while (Serial.available() > 0)
{
char IncomingData = Serial.read();
readString += IncomingData ;
temperature = readString.substring(0, 3);
gas = readString.substring(4, 7);
breaks = readString.substring(8, 11);
//Serial.print(IncomingData);
// Process message when new line character is DatePrimite
if (IncomingData == 'p')
{
Serial.print("temp=");
Serial.println(temperature);
temperature = ""; // Clear buffer
Serial.print("gas=");
Serial.println(gas);
gas = ""; // Clear buffer
Serial.print("breaks=");
Serial.println(breaks);
breaks = ""; // Clear buffer
readString = "";
}
}
}
data_string.ino (1.13 KB)