Detecting input pins connected to each other

Hello everyone!

I've been working on developing a "keyglove" prototype as a personal experiment, and I decided to use an Arduino board for the hardware end of things since it seems like a perfect tool. I don't have the board yet, so I can't test anything, but I've been working on the source code and I've run into a conceptual problem.

Basically, the keyglove has 25 sensors on it which are electrically nothing more than wires that go nowhere. They aren't buttons, just conductive pads. I have come up with a design that works in principle by detecting which sensors are touched together. This approach allows a whole lot of possibilities without being ergonomically difficult.

My problem is this: it doesn't seem possible to detect simply which digital pins are connected together. It might be a terrible idea to short them under any circumstances, I'm not sure. I know you aren't supposed to short two pins in output mode together at least.

So here are my questions:

  1. Is it possible to detect shorts between I/O pins?

  2. If not, is there a safe way I can rapidly alternate which pins are input and which are output so I can functionally accomplish the same thing?

For question 2, here is what I am thinking. If the hardware runs fast enough (I assume it does), I can check for continuity by doing the following for every possible pair:

  1. Set first pin to OUTPUT MODE.
  2. Set first pin to HIGH.
  3. Test second pin for HIGH and record value.
  4. Set first pin to LOW.
  5. Set first pin back to INPUT MODE.

This process would be run in a loop for each of the 45 ergonomically possible combinations of 1-to-1 sensor shorts, thereby building a simple binary array (probably just two integers for bit masking later).

Using this approach is not programmatically difficult, but it seems like a tremendous amount of overhead for something that might be much easier and I just don't know it. It seems like a safe approach, since no two I/O pins will ever be shorted together while more than one of them is in OUTPUT mode. The explicit setting of modes and logic levels should prevent that.

But is there anything I should consider about inherent properties of the Atmel chips or the Arduino board that would make this fast switching NOT behave as expected? Or, is it likely that this switching loop would be so slow as to prevent a reasonable speed of using the glove?

In short, will this work, and is there an obviously smarter way to do it?

I am open to using analog inputs and some kind of multiplexer, but I'm fuzzy on hardware and much more at home working with code. I think I would need a lot of help (or tutorial links) to go that route.

For more info on my idea and approach, read the post from 9/28 on sectorfej.net (I would post a proper link, but it won't let me since this is my first post). That post also has an image of my glove sensor arrangement.

As a follow up, since the board should let me now, here is a proper link to the above mentioned blog post, and the glove sensor arrangement image:

As above, you are on the right track. One property of the microcontroller you can use is the existence of pullup resistors. An input will be high (with pullup enabled) until forcibly driven low. So the easiest approach (I think) is:

Setup: enable all pins as inputs with pullups

  1. Set Pin 1 as an output and drive it LOW
  2. See which other pins are now LOW -- they are connected to Pin 1
  3. Return Pin 1 to be an input with pullup.
  4. Set Pin 2 as an output and drive it LOW
  5. See which other pins are now LOW -- they are connected to Pin 2
    etc.

--
The Gadget Shield: accelerometer, RGB LED, IR transmit/receive, light sensor, potentiometers, pushbuttons

Thanks to both of you for your help! The loop implementation works great. I'm well on my way to getting this thing off the ground. I've made some design changes since my last post (mainly a few more sensors), and it looks like it could be an excellent device once the rest of the hardware I'm waiting on shows up.

I've put together a project website for anyone interested:

Thanks again!

Jeff