This is a part of a program i am writing. processing is working with arduino, that send on serial a string with millis(), the data that is read from his distance sensor and a value that indicate what sensor is connected to arduino.
It seems that there is a loss of data during the transfer because tre program give me an "ArrayOutOfBoundsExceptions" when i call lettura[2]. someone can help me?
void acquisizione()
{
String myString = null; //string that read the data form Arduino
if (porta.available() > 0)
{
myString = porta.readStringUntil(10); //read until new line
if (myString != null)
{
lettura= split(myString,':'); //split the values of time, distance,and the type of the sensor in an array
if(gira==1) //if the program is going
{
letturaTempo=float(lettura[0]); //save the time into a float global
letturaSpazio=float(lettura[1]); //save the distance into a float global
}
println(int(lettura[2])); //ERROR
porta.clear();
}
}
}
this is a part of a program i made to draw with processing a grafic of distance acquired with the ARDUINO board.
to send the data to the function grafic i need to join the array in the main with the function join and then i have to split it in the function but in the 5th line processing found an error:
expecting DOT found 'dato'