We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Dear All,
I am new to JAVA and processing. Can you tell me that how can I receive three serial data from arduino uno.
I am sending three parameters from arduino as.
Serial.print(i);
Serial.print(",");
Serial.print(D1);
Serial.print("_");
Serial.print(D2);
Serial.print("."); // termination.
But I do not know how to receive the three different data. Yet I am sucessful to receive TWO of them.
Please help me Sir/ Madam
Answers
http://forum.Processing.org/two/discussions/tagged?Tag=bufferuntil()
I have tried with this.. please check
void serialEvent (Serial myPort) { // starts reading data from the Serial Port // reads the data from the Serial Port up to the character '.' and puts it into the String variable "data". data = myPort.readStringUntil('.'); if(data != null){ data=trim(data); int inputs[] = int(split(data, ',')); if(inputs.length == 3){ iAngle = inputs[0]; iDistance = inputs[1]; iDistance2 = inputs[2]; } } }
Please see the above codes and tell me is their any thing wrong. I am not getting the value of iDistance2 i.e., third value from the serial port.
Heee... I got the answer.
the code should be like this
` void serialEvent (Serial myPort) {
data = myPort.readStringUntil('.'); if(data != null){
String[ ] a = split(data, ','); println(a[0]); //print Value1 (in cell 1 of Array ) println(a[1]); //print Value2 value println(a[2]);
iAngle =int(a[0]); iDistance = int(a[1]); iDistance2 = int(a[2]);
} `
http://forum.Processing.org/two/discussion/8045/how-to-format-code-and-text