Hello, I have a problem, I'm sending data from my arduino to Processing, the data is just 3 values : Yaw Pitch Roll
I'm sending them through Serial.print, and from Processing I split them back into 3 separate values. The problem is, when I try to print the value of ypr[1], the debugger gives me an "ArrayIndexOutOfBOunds:1" error, I get that it's talking about ypr[1] but i checked multiple times and ypr does have 3 entries, ypr[0] works fine but ypr[1] and ypr[2] give errors.
I tried 2 different ways to split the string, they both fail.
Serial data handling does not belong in draw(). Use the serialEvent() method.
Printing what is actually in myString is the first step. Make an array of strings, and make sure that splitTokens() actually doing what you think it is.
Thank you for your help,
I'm sending the data in real time from the Arduino through a Serial.print wich looks like this : "Yaw,Pitch,Roll", in Processing I read thoses values from the serial input and I separate them into the ypr array.
I did check all the values before and after the split, myString contains exactly what is sent and println(ypr); gives me the 3 values separated into [zero] [1] and [2], but when I try the call ypr[1] or ypr[2] anywhere, it gives me the same error.
Sorry I'm new to Processing, draw() just seemed like the loop() of the Arduino so I just put it there but that was never suposed to be my final code anyway, I wanted to do stuff with this data afterwards, but I'm still stuck here. I'll put the code in serialEvent and see if that works better tomorrow, but that seems like a long shot.
PS : I also tried the ypr.length command and is says the array has a length of 3, wich is what its suposed to have
I'm sending the data in real time from the Arduino through a Serial.print wich looks like this : "Yaw,Pitch,Roll"
Useless information! Post your CODE!
I did check all the values before and after the split, myString contains exactly what is sent and println(ypr); gives me the 3 values separated into [zero] [1] and [2],
But, you're not going to show that code or the actual output. Fine. Good luck.