Hi, I have a question about how the switches and circuit in a keypad work. My understanding is that each switch has two pins, one pin is connected to the row wire and the other connect to the column wire.
There needs to be diode too to prevent ghosting. diode can be installed in either the row wire or the column wire, as long as there is one diode per switch.
Now here is my questions: looking at the switches belonging to the same row wire, should the switches block the wire connection or be on the side? Like switches shouldn't be in the row wire but on the side of it. Just like the image on the right:
Awesome looks like my understanding is correct. Is 10k the conventional resistance for each row and column wire? Does the diode and resistor value have to change just because I am planning on building a 19 by 19 grid?
The following (Fig-1) is the internal structure of the 4x4 Keypad that we usually use with Arduino UNO. There are no resistors and diodes. However, it works well by virtue of the Keypad.h Library.
Probably, the Library adds the internal pull-up resistors (Fig-2) of the IO lines of the MCU with the Row Lines of the Keypad.
I am using a uno for testing prototype and have a mega for the high number of pins. @er_name_not_found do you mind sharing more details of how you reduced pin count?
You have to provide an output for each column pin C1-C4 in the diagrams posted by @GolamMostafa
You can use a decade counter (CD4017) or two to do this in sequence by using one pin for the clock and one for the reset. You can chain decade counters by splitting the clock and reset signals for both and using the carry outs as the clock inhibits for each other.
With two decade counters you can provide up to 20 columns.
Edit: If you want to use multipress, I think you have to add diodes to all the decade counter outputs to prevent feeding current back into the chip the wrong way.
Which is not the case for the little membrane keypads as well as others.
If the new keypad is modeled as the schematic provided by @LarryD then the diodes are included and can be omitted, as you say.
The 4x4 Keypad that goes with Keypad.h Library is a Walking-0 keypad. The Row Lines of the keypad are terminated by pull-ups and the Column lines are scanned by a Walking-0 (Fig-1 of post #6) of about 1 kHz. Whenever a key is pressed, the corresponding Row Line assumes LOW state which immediately appears as an information to the MCU.
I would say that the column lines are not shorted; rather, multiple keys could be pressed at the same time.
As the said Keypad does not have built-in electronics like PC's Keyboard or an 8279 Keyboard Controller, it does not support 2/n-key lock out; where, all the pressed key must be released except one key for recognition.