I know Firmata makes this process much easier, but I'm interested in understanding the serial communication better. I think the example on this page has some errors (or I am misunderstanding something).
first question is about the line:
firstSensor = analogRead(A0)/4;
Dividing by four means that the processing sketch is only receiving a value between 0 and 255, which is the opposite of what we want. I deleted the /4 and it works much better.
the second is the line:
inByte = Serial.read();
This seems extraneous - inByte is never called again. Is it necessary for some reason or a holdover from an earlier example?
Probably a hold-over from a sketch where the input is used for PWM output. You were right to remove the /4 since the Processing code expects values from 0 to 1023.
inByte = Serial.read();
This has to be done to acknowledge the "call" part of the "call/response" protocol. If you don't get the byte out of the buffer the (Serial.available() > 0) test will continue to be true and return values will be sent continuously, possibly faster then they can be processed. The "inByte =" part isn't necessary.