Processing: should I use Firmdata ?

I was trying to interact with processing using an Arduino nano. It should be a bidirectional interaction and I'm having problems. From arduino to processing works fine, but when I try to send data from processing to Arduino, then it is very slowly. I was looking for help and I found the firmdata code. Is this the way I should go ? Install firmdata and program everything from processing ? Thanks !

what do you mean is slow? it should communicate at baudrate speed. maybe on the arduino code you are usong bloacking serial like while(Serial.avaiable>0){...} ??

Ok, solved. I used the processing examples but they are no so good IMO. The problem is that the serial buffer is saturated. The solution is to send / receive only when there is a change in the state. For instance, on the arduino side:

oer=analogRead(OER)>512?1:0; oef=analogRead(OEF)>512?1:0; odr=analogRead(ODR)>512?1:0; odf=analogRead(ODF)>512?1:0; b1=oer+oef*2+odr*4+odf*8; if (b0!=b1) { // send only if state changed Serial.print(b1,BYTE); b0=b1; } ... delay(100);

The same for Proessing.

If someone needs help, just ask me and I post both codes :)

you can calculate the amount of data for serial in this way:
baud rate is the number of symbols you can send per seconds…

you can also clear the buffer with Serial.clear(), both in processing and arduino.

you can also clear the buffer with Serial.clear(), both in processing and arduino.

Some people actually use the Serial.flush() function to do that, but, it really isn't recommended, since it throws away random amounts of unprocessed serial data.

Sending data only as fast as it can be dealt with is a much better solution.