Program slower when I send data to Arduino

Hi @bking, In general there are two ways to solve the problem. The easy way is to reduce your requirement, the more complicated solution is to understand exactly what’s happening and maybe you can fix it. Easy way first, to get it out of the way, send to the Arduino less often, e.g.

if (frameCount % 10 == 0) {arduinoPos();}

Your frameRate is 80, I wonder if it is achieving that, but assume it is for the moment. In arduinoPos function you have for loop sending 5 times? why? What is the length of the message? Looks like 25 chars to me. How many bits per second? = chars * bits/char * num/sec = 25 * 11 * 5 * 80 = 110000. and the baud rate is 115000. So you are very close to the theoretical maximum rate. This is without thinking whether the PC or Arduino are limiting things.

Processing’s console (where the prints() go) has it’s limitations. If you print too much or too fast it can hang up. I think you are near/beyond it’s limits.

1 Like