But bear in mind this is limited to a single channel at a maximum data rate of around 200kHz
Udo's in the playground seems somewhat better in the task (though more difficult to follow, and you need to use the avr tools directly according to the comments to get it into your arduino); it uses an unrolled loop in assembler to sample a single port (D) quickly 1024 times upon a trigger on one of the pins (via a bitmask), then prints the results to the serial port.
http://www.arduino.cc/playground/Main/LogicAnalyzer
Personally, it seems like a better option, even if it is more difficult to follow; I think if you took it, made some modifications to it, added on a button interface and a KS0108 GLCD gui - you would have a very nice little low-cost logic analyzer...
One thing it does seem to lack is any form of inter-sample timing; it is basically digitizing the port as fast as possible, each sample "in between" time is the number of clock cycles for each "set" of sampling instructions in the unrolled loop (it turns off the interrupts during the sampling phase, I think, so they don't cause issues, then turns them back on after it is done).
It looks like it was written for the 168; I am not sure if you would need to modify anything for the 328 (you could increase the sample buffer, though).
![]()