I wanted to combine the Arduino's led sensing capabilities with Processing. It's simpler than I thought.
Arduino can send serial signals back to the computer over USB, at 9600 baud. The arduino sends the value of the time it takes for the cathode of the sensor LED to fall. (What this 'value' is based on I'm not sure -- as seen in the post before, it's measured by a while loop that increments a counter with no delay. It probably depends on the clock of the chip or something like that.) We can send said values with Serial.print().
Processing has libraries for serial input that are built-in. Serial() is a constructor for a Serial class that initializes a serial connection, read() reads a value, et cetera. By checking whether or not the serial connection is available, then reading input, we can get the value of the input.
I whipped something up that takes the values of the input and stores them in an ArrayList, deleting the oldest value, and adding the newest one. This way, deleting elements and adding them are constant-time. The bars representing the older values are darker, while the newer values are lighter, and for the sake of being pretty, I mirrored everything.
Here's the Processing code.
And here's what it looks like:
My hand is unnaturally yellow, and that isn't James Brown in the background but Justice.