Thanks! That was extremely useful. It seems that there's a synchronization problem between the rate the arduino is outputting data and the rate that the program is reading it.
First, I reprogrammed the arduino to output comma-terminated data instead of CR-terminated, since it's easier to see. result is the arduino gives me data like the following:
Code:846,821,799,779,770,756,749,741,730,727,723,717,714,712,714,711,712,717,719,721,728,731,736,741,742,748,753,755,759,764,766,771,774,781,783,784,
788,787,787,789,788,787,786,780,779,778,776,775,774,776,775,774,773,774,775,776,781,786,786,724,666,607,548,490,430,370,306,242,186,186,186,187,188
using println("value##"+n+"##"); on that incoming data gives the following:
Code:value##9,9,9,9,10,10,10,10,10,##
value##10,8,8,##
value##8,8,8,7,7,##
value##7,7,7,7,7,7,##
value##7,7,8,7,7,7,7,7,7,7,##
value##8,8,8,9,8,##
value##8,8,9,9,##
value##9,8,9,9,9,9,##
value##9,9,8,8,8,8,7,7,##
value##7,7,8,##
value##8,##
So yeah, the problem is definitely a synch error. :p
I'm going to try taking the string data and splitting it at the commas and putting it in an array instead. For the record, any idea what I might do to get these synched properly? I have a 20-msec delay between updates on the arduino, so a 50hz sampling rate; I set the framerate of the Processing code to 50 as well, but it doesn't help.
Thanks again.