Read keypad with shift register

Hello,

I have been thinking about an idea, and I wanted to throw this out to see if it can be done.

If I use a 4x4 kay pad, I need to use 4 pins for the cols and 4 pins for the rows, 8 pins in total. Is it possible to use a 8 bit PISO shift register to read key presses from the keypad? If so, how exactly?

As I understand it, the method to find a key press is to set a row pin high and poll the col pins, repeating the process for each of the row pins in turn. I can see how you detect a high pin with the shift register, but how would you be able to set the row pins high?

Is this possible? If not, are there any other ways to reduce the number of pins needed for a keypad?

Thanks,
Adam

Solutions depend on the actual wiring.. Is this just a matrix (which would mean the output is undefined when more than one key ispressed)? Or are there diodes added at each crossover?

The solution you are insinuating needs write and read, which is normally in two different chips. You will need only half of both for this small keypad..
However there is a thing called I/O expander that connects readily to the TWI pins of the Arduino.
http://www.nxp.com/documents/data_sheet/PCF8574.pdf
It allows you to write 4 pins and read 4, with a simple software interface.

The drawback is its prize around $2 in contrast to 50 cents for a SIPO or PISO chip...

Hi deSilva,

The keypad is a simple 4x4 keypad like the one shown here:

You are right, this solution requires a read and write. I'm guessing this cannot be done with shift registers. Would you be able to to the reading only with a shift register? so you would map the row pins one to one with arduino pins to set the rows to high in sequence, and read the col pins with a shift reg? Although this solution will not save many pins. :slight_smile:

Thanks.

Alas , the link is not very descriptive... Let's assume it has just 8 wires in it and no diodes or such...

You have multiple options; in fact this is one of the basic homeworks students have to do in their first or second semester for at least a generation now...

Set the voltage to 1000, 0100, 0010, 0001 at the column side by an (avtive high!) decoder chip (74HC238); this will need 2 lines from the Arduino.
Read any voltage from the four rows with a priority encoder chip (74HC147 or 148); this will need 2 input lines.. Makes 4 rather than 8.

A shift register has little advantage in such a small configuration...

You might notice that you also did use half of the encoder/decoder capacities only...

A quit tricky solution with an eight bit SIPO - - as 74HC164 will need four additional AND gates. Can you imagine? Then ORing their 4 outputs to one input signal for the Arduino. But this will sadly also need 4 processor lines (clock, data, strobe, input)

I should still prefer my original proposal.. That will need the 2 I2C lines only...

Edit

Those kinds of keypad are still my favourites... Thye need one (analog) pin only...