hiduino:
As for the color changing rate problems you are seeing, it appears to be a serial buffering issue. The Arduino is sending reading sample updates too fast for Processing to keep up with. I don't know why they made the Arduino code sample that fast (1 millisecond delay is about 1000 samples per second), it's not really necessary.But here is a quick fix workaround to this. Change the sample delay from 1 millisecond to 100 milliseconds. This should slow down the Arduino sampling slow enough for Processing to keep up with.
Try this:
void loop() {
// read the value of A0, divide by 4 and
// send it as a byte over the serial connection
Serial.write(analogRead(A0)/4);
delay(100);
}
There is a way to fix this issue changing only the Processing code to clear the buffer after reading a byte:
if ( myPort.available() > 0) {
// read the value and store it in a variable
bgcolor = myPort.read();
myPort.clear();
// print the value to the status window
println(bgcolor);
}