SparkFun Forums 

Where electronics enthusiasts find answers.

For the discussion of Arduino related topics.
By victorf
#122665
I want to interface a 4 X 4 matrix keypad from Grayhill to an Arduino. My idea it to interface the keypad to a PCF8574 I/O expander. The keys are arranged:
1 2 3 A
4 5 6 B
7 8 9 C
* 0 # D


The keypad brings the matrix out on an 8 pin SIP with 4 pins for the rows and
4 for the columns. I plan to connect the pins in this order on the 8574.:
Row0 - P0 Row1 - P1 Row2 - P2 Row3 - P3
Col0 - P4 Col1 - P5 Col2 - P6 Col3 - P7

Do I need to connect pull-ups for all row/col lines?

I will read the 8574 data into a byte variable which will give me the key-press data with the high nibble being the column data and the low nibble being the row data. Pressing the 1 key should then return 0001|0001 and a 2 would return 0010|0001 and a D would return 1000|1000 if I am thinking correctly. How do I extract the row number and the column number from the byte?

Also, the 8574 has an interrupt that notifies when any change occurs on any pin. Should I consider using that feature to notify the application when there is a key-press?
By qema
#122902
Hi victorf

Can you post the links to the datasheet for the hardware? It's hard to help you if i don't know what your working with.

If you keypad works the same way as http://www.sparkfun.com/products/8653 I would suggest you set up the Columns as inputs (with pullup) and the rows as outputs. Keep the outputs HIGH(5V). If you change one of the inputs to LOW(0V) you should see the input change if a button on that Column is pressed. If you don't see a change make that output HIGH(5v) again and make the next output LOW(GND) and check for a change of state.

Cheers
Q
By monk
#123035
You only need pull-up resistors for lines that are connected to the inputs of the Arduino, be that the rows or columns.

If you want to see the sketch for a door lock project based on a keypad, you can download the sketches for the projects in the book 30 Arduino Projects for the Evil Genius here: http://www.arduinoevilgenius.com

If you want to avoid pullup resistors, you can use the ones built into the arduino pin hardware. These are turned on if you set the mode of the pin to INPUT as normal, but then do a digitalWrite(inputPin, HIGH);

Sounds mad, but it works.