Receiving data from arduino

HI! I’am having problem with my code, iam able to read the data, on arduino serial its fine but on Processing its too much slow, i dont have a clue about whats going on.

void recebeData(){
   val = myPort.readStringUntil('\n');       
   if(val != null){
   str = split(val," ");                     //split data with space
  num = float(str);                           //convert to float
   gx = num[0];  
   gy = num[1];
     print("ERROR ");

1 Like
1 Like

I’m still learning, but shouldn’t this be an array, like this:

str [ ] = split(val," "); //split data with space

where the square brackets define an array that is populated with data from the serial? Not sure if this is the issue causing the slow rate, or if it’s an issue at all…

How slow though? Are you getting just the first line, or is the rate of new data slow? Is it updating past the first few lines of data?

I’am sorry, i forgot to put the global variables on the code, i’d declare the variable as an array already, but tanks!

String[] str;
float[] num;
float gx,gy;

It work! thank you very much for your help!
I was getting something near to a single read for second, now its working on the same rate as the arduino send :wink: )