Shift register for 34 rapidly changing I/O pins

I'm looking for a way to use one or more shift registers to reduce the number of digital I/O pins required for my Keyglove project (http://www.keyglove.net). I have a total of 34 sensors, each of which uses one pin. The controller code tests for conductivity between pairs of pins by looping through each possible pair, setting one to output LOW, and then checking the other's level (the default is HIGH). If the input level is LOW, then the sensors are touching.

I am prototyping with an Arduino Mega board, so I have enough pins without any extra work or hardware. However, the Mega is a very large board. I was looking at possibly using something like the Teensy board (only 1.2 inches in the largest dimension) for the final product. The Teensy++ has 46 I/O pins and would get the job done, but it's larger.

I realize that the size different between a Teensy and a Teensy++ (a whole 0.8" in length) is likely to be no worse than using a separate shift register. However, I'm still curious: is it possible (and easy) to do what I'm proposing?

Any workable solution would need to be able to set and hold one pin in output mode at a specific level while testing a separate pin immediately afterwards. This is why I was looking at shift registers instead of multiplexers. 34 is larger than most people use though (and sadly larger than 32 bits, which might be simpler).

Any ideas? I may just stick with a Teensy++ board and be done with it, but the concept is intriguing to me anyway. I'd love to know how to do it even if there are alternative options.

i just went through a similar exercise for output puts. I happened to be using a plain ole BBB, and did some experiements. Resulting code was trash and not really usable.

see http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1285804491

Not a shift register per se, but a general purpose I/O expander such as the MCP23017 (I2C interface) will fit the bill.

Not only do you get 16 inputs and outputs, but you get goodies like pullup resistors and interrupt-on-change capabilities in the package as well. You can easily hang 3 on the I2C bus and get 48 GPIOs.

Ah, Professor Chaos! That sounds perfect. I knew there had to be a simple way of doing what I had in mind. Now that you mention that, I think I came across just such a solution about a week ago while I was looking for something completely different.

I think for the extra 0.56 sq. in. that comes with the "++" version of the Teensy board, I'll just stick with that. I can guarantee any solution I came up with would take a whole lot more space. The larger board has enough I/O pins for my project as-is.

Thanks to both of you for your input.

You might like to consider the MCP23S17 it is similar to the one described above but it has an SPI interface and so you can access it faster.