Keypad 3*4 matrix Pin Configuration for using Keypad.h

Hello, this my first question here. Just working on a keypad bought online.
I used the example in the arduino website, but pin diagram doesn’t work properly. Only first column is right, the other numbers are all swapped .
Checking pins out with multimeter and continuity seemed ok, as shown in the pictures. Also, tried to modify the numbers of the matrix in the declaration code. But, it just doesn’t work.

#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
{‘1’,‘2’,‘3’},
{‘4’,‘5’,‘6’},
{‘7’,‘8’,‘9’},
{’*’,‘0’,’#’}
};
// Connect keypad ROW1, ROW2, ROW3 and ROW4 to these Arduino pins.
byte rowPins[ROWS] = { 5,4,3,2};
// Connect keypad COL1, COL2 and COL3 to these Arduino pins.
byte colPins[COLS] = { 6,7,8 };

// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

Please, any help or experience with this kind of phone keypad and library keypad.h would appreciated. Set up pins as shown in the code.Currently, when pressed: obtain:

::
1:9:
2:0:
3:1:
4:2:
5:3:
6:4:
7:5:
8:6:
9:7:
0:8:
#:#:

Welcome to the group.

Show us a good schematic & image of your circuit wiring.
Posting images:

Use CTRL T to format your code.
Attach your sketch between code tags
[code]Paste your sketch here[/code]

Hi Larry, thanks for your quick response. The picture attached is the one provided by online vendor. Sorry, posting from mobile, so unable to use CRT T. Basically the pin diagram of keypad is:

|Pin1|Pin2|Pin3|Pin4|Pin5|Pin6|Pin7|

|Col3|Col2|Col1|Row1|Row2|Row3|Row4|

As per declaration in the code, column1 going to arduino digital pin6, column2 to digital pin7, and column1 to digital pin8. Row1 going to digital pin5, Row2 to digital pin4, Row3 to digital pin3, and ROW4 to digital pin2. In fact, there some issue, as every keypad digits readable, but the char taken are different than keypad numbers.

#include <Keypad.h>

const byte ROWS = 4; // Four rows
const byte COLS = 3; // Three columns
// Define the Keymap
char keys[ROWS][COLS] = {
  {'1','2','3'},
  {'4','5','6'},
  {'7','8','9'},
  {'*','0','#'}
};
// Connect keypad ROW1, ROW2, ROW3 and ROW4 to these Arduino pins.
byte rowPins[ROWS] = { 5,4,3,2};
// Connect keypad COL1, COL2 and COL3 to these Arduino pins.
byte colPins[COLS] = { 6,7,8 }; 

// Create the Keypad
Keypad kpd = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

Hope it is enough information to get support from this forum. Thanks

No pic attached. Out of interest is this the typical white tactile keys in a black plastic rounded corner case or a membrane keypad ?

Hi, yes it is according to your description. Picture attached. Thanks

Ah yes. Now it may be as diagram above BUT I have one of those and the pins are nothing like. They are peculiar as in row col row row or somesuch.

I will dig out the paperwork.

Ok got it. Try this. Looking from keys side, the pins are.

C2 R1 C1 R4 C3 R3 R2

It may be different but I spent ages determining mine compared to vendor pinout diagram

I checked out the pins with multimeter and the pin diagram provided by vendor seemed ok. Just afraid if I was using the declaration of pins wrongly in the code. Also I tried to swap the numbers of the matrix in the code, but doing this, only got the digits 1,4,7,*,0 and 8 working fine, anyway, it’s quite difficult to understand for me, as every key of keypad return a character, and the first column working fine, how possible other columns and rows are giving different characters... Thanks Tasmod for your support. I will try your pin configuration. Best wishes

good and bad news... the bad ones, tasmod, your pin configuration doesn’t work on this, also unabled part of the keypad, so it might be an issue with the rows and columns as every key of the keypad is readable. The good news, I had a time to think about how avoiding few ages sorting the pins out, and have decided to program a matrix conversion function, therefore, every time I read a character, it calls to the matrix conversion function and return the desired number pressed in the keypad, so much easier.
Indeed, contacted the vendor in the UK, and they sold hundreds of units without any issue.
Therefore, I guess or buyers found a similar solution, or they more lucky in the pins config process, as every key are readable from keypad. Anyway, thanks a lot for your support, hope this thread helps next one who buy a new phone keypad online.
Probably will back with new questions about 8 digits 7 segment displays 74HC595 modules soon. All the best! Keep arduino programming!

I use this type of keypad quite often.
It might be similar to yours.

2.jpg

Had to add two jumpers.
Rs and Cs.jpg

Your keypad:

63d8f861a6aeaca4e8694fe0febbca0ac0c09af4.jpg 126257a64ba855b2968e950c3b677a04188501c4.jpg

Hey Larryd, hope you had better experiences with these keypads.
I wish we could find a methodology for their key encryption one day.
Or definitely better would need to find another seller tho. But, this keypad seemed quite nice.
Just messing around with their pins, it’s a lottery at the moment.
Do you think would need to modify the library for this keypad at the end? Or programming the keypad my own code, no libraries, putting resistors and 5 volts to the rows? Thanks

I had to take one of my keypads apart to see what needed modifying, hence the addition of two jumpers :frowning:

Carefully remove your PCB (6 screws) from the bezel.

Show us the foil side in a good image.

At this moment, I see no reason why your keypad would not work.

Thanks Larryd, as soon as opened discovered a three holes on top of lines cutting PCB copper, coolie shame, great advise, so just need to make a jumper…

See post #15

You are good to go!

image.jpg

OOPS, you have an odd angle on this image.
The header pin on the LHS has no connection.

You do ‘not need’ to change a thing on your PCB.

image.jpg

And that pic is wrong too !

Pin assignments need moving one to the left. It's the far right pin that also has no connection.

Thanks Larryd, it’s very easy to read the lines with this picture.
Just wondering if the problem comes when fitting the screws back to the back cover, maybe lines crossing along screw housing are shorting the circuit... in fact, this keypad model leading to dissapointment, but I appreciate your support. It’s a quite interesting experience anyway

Yeah screw housing may cause short circuiting, btw Keypad Arduino Interfacing isn't that difficult as depicted from this thread

If there are no broken traces, your keypad will work fine.

I doubt very much, that the screws have anything to do with your problem.

Put the unit back together.

Measure the resistance between C1 and R1, what do you get when #1 is pressed?

Between C2 and R1, pressing #2? between C3 and R1, #3? C1 and R2, #4 . . .

Do all the remaining switches?

My switches measure about 20Ω which is fine.