Arduino Single Channel Logic Sniffer

A few projects people undertake on here are in need of some form of logic analyser/sniffer but paying $50+ can be expensive so I decided to attempt a free simple single channel solution. It needs no extra hardware beyond a basic UNO and for software only needs the freely available processing that works on Linux, Mac & PC platform.
Up until about one week ago I had never seen/used processing so the code I wrote leaves a lot to be desired and is still classed as 'work in progress'. The project is not perfect and fails with really fast signals but for stuff like serial, I2C & IR remote it seems to work fine.

To use, you need to upload the sketch to your UNO and then connect the signal you want to capture to pin 2 (The usual disclaimer here about ensuring the signal is suitable to connect to the arduino pin).

Load the processing project and run it, if it detects the arduino and the sketch it's running then you should get a window open with a little red circle top left. Next to the red circle is a blue square then a green square and then a couple of numbers. Below all of this is an up and down yellow line that is the sampled data. The initial sample you see is loaded on startup so you can just see something but when you start sampling it will be delete and replace by your capture data.
The red circle is the record button, pressing this starts the arduino ready to start capturing data.
The blue square is the stop button and will stop the arduino from capturing any more data.
The green square is the trigger direction button that toggles between 0 (low) and 1 (high). When you start recording by pressing the red circle the arduino does not start sending data until the capture pin (pin 2) changes to match the trigger.
The two numbers show the offset from the beginning of the captured data and the scale of the displayed data. You use the UP/DOWN cursor keys to alter the scale and the LEFT/RIGHT cursor keys to move back and forth along the captured data. Pressing 'Enter' will reset the position and scale back to there default values.

Attached are the latest versions of the Arduino and Processing sketch's

Logic_Scanner.ino (8.12 KB)

Logic2.pde (8.85 KB)

Some good sample captures.
I2C, Serial, IR remote & Manchester.

Some not so good sample captures with what they should have looked like.
1-Wire & SPI clock