0
\$\begingroup\$

I'm working with a Raspberry Pi. I want to be able to connect any two of 7 pins together in a matrix fashion to control a device with a keypad input. This means I need to be able to short any of the 3 horizontal pins to the other 4 vertical pins. I'm not sure if this can easily accomplished with the GPIO pins. Are there any IC's I can do this with or would I need to accomplish this with some kind of transistor?

If at all possible I would like it to be jellybean parts and as few parts as possible. If I can get away with 7 transistors or even just using the GPIO pins somehow that would be fine.

\$\endgroup\$
  • \$\begingroup\$ Like every 4x4 matrix keyboard, search for it. \$\endgroup\$ – Marko Buršič Feb 21 '16 at 8:26
1
\$\begingroup\$

The easy solution is to use two analog 1:8 multiplexer chips. Connect both 8-sides to your 7 matrix pint (leaving one input unconnected), and the two 1-sides together. Now you can use the two 3-bit address\es to specify the two pins that must be conneced.

A much more difficult but no-components solution is depends on figuring out how the matric is used, presumably 3 or 4 pins are outputs from the controlling device, and the others are inputs. Use your GPIOs to sense what is output, and put the pattern that corresponds to the key you want pressed on the inputs (=your outputs). You must do this faster than the controlling device scans the keys.

\$\endgroup\$
  • \$\begingroup\$ Actually, I think this might work well if there is a multiplexer that has an output enable pin on it. What I'm picturing is a device wehre I could have it as all 7 pins with Normally Open switches on them, commonly connected to one 'bus'. Unfortunately I'm not familiar with many IC's, do you know of any that could accomplish this? The first thing that comes to mind is basically an 8 channel opto-coupler. \$\endgroup\$ – Korozjin Feb 21 '16 at 20:37
  • 1
    \$\begingroup\$ Use two 8-channel analog muxes, 4051 or one of its siblings. (I assume you don't know which of your 7 pins is input or output.) An analog switch is bi-directional, so it has no input-output distinction. A 4051 has an enable input, but as you have an 'unused' pin (you need 7, the 4051 has 8) you can select that one to disable your crossbar. \$\endgroup\$ – Wouter van Ooijen Feb 21 '16 at 20:41
0
\$\begingroup\$

This shouldn't need any extra parts turn on the internal pull-ups on the pins, configure the pins as inputs when you want them to behave as high-impedance.

set one of the columns as low impedance and low, read all the rows, the the column high impedance again. repeat for the other rows.

\$\endgroup\$
  • \$\begingroup\$ I don't think this will work because I need the connections to be low-impedance (short circuit, really). Also the pull ups should have some kind of resistance of 10k to 100k I'm guessing, right? Which in series would be twice that value, which is still too high. \$\endgroup\$ – Korozjin Feb 21 '16 at 20:19
  • \$\begingroup\$ there's no reason for it not to work. \$\endgroup\$ – Jasen Feb 22 '16 at 0:55
  • \$\begingroup\$ @Jasen - the poster isn't reading a keyboard, they are impersonating a keyboard for some other device designed to read one. \$\endgroup\$ – Chris Stratton Feb 22 '16 at 6:48
  • \$\begingroup\$ he says keypad in the second line \$\endgroup\$ – Jasen Feb 29 '16 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.