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\$
1
  • \$\begingroup\$ Like every 4x4 matrix keyboard, search for it. \$\endgroup\$ Feb 21, 2016 at 8:26

2 Answers 2

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\$
2
  • \$\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, 2016 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\$ Feb 21, 2016 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\$
4
  • \$\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, 2016 at 20:19
  • \$\begingroup\$ there's no reason for it not to work. \$\endgroup\$ Feb 22, 2016 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\$ Feb 22, 2016 at 6:48
  • \$\begingroup\$ he says keypad in the second line \$\endgroup\$ Feb 29, 2016 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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