good it is working, still allow a comment on the used arduino code:
-
a map from 1023 to 300 ( int) is nearly a reduction from 10 bit to 8 bit ( 256) resolution.
why you do that?
just send the raw int values to processing, and there can map to float without losing
resolution. -
a low baud rate 9600 and a high sample rate ( 50Hz / lines per sec ) looks like a strange combination to me, but yes, wiring problems / bad communication / noise… / can be a reason for this.