4x4 keypad LIB updated to 5X4 (20 buttons)

Hi All!!
My name is Frank, and i was using a lot this prety Arduino!
I designed my own development boards and others with ATMega168 CPU

This is a simple contribution, i’m using for some proyect the keypad library modified to use 20 push-buttons, i think it can be modified for any keypad size.

Remove the old part from keypad and copy this:
#include “keypad.h”

extern “C” {
#include “WConstants.h” //all things wiring / arduino
}

// --------- PIN MAPPINGS -------------------------------
// The pin mappings are matched to the pin numbers found on the Arduino. For example
// the first column from your keypad is connected to pin 6 on the Arduino and the
// second column is connected to pin 5. It’s the same for the rows.
// These are the numbers you would change to match your keypad wiring. Even though
// they are shown in order you can set them to any valid (random) pin number.

#define COL0 12
#define COL1 11
#define COL2 10
#define COL3 9
#define ROW0 13
#define ROW1 14
#define ROW2 15
#define ROW3 16
#define ROW4 17

// Note: The column pins will be set as outputs and the row pins will be set as inputs.

// Default row and col pin counts. Don’t change these here. You can set them in your
// code when instantiating a new keypad object. See the example project.
int num_rows = 5;
int num_cols = 4;

static int col_select; // Keeps track of which column to activate/de-activate

// 4x4 keypad key mapping. You shouldn’t need to touch this unless you have
// a keypad with different (or more) keys than those listed.

const char keymap[5][5] = { :o (rare keypad! i know!)
“ABCD”,
“EFGH”,
“147*”,
“2580”,
“369#” };

int row[5] = {ROW0, ROW1, ROW2, ROW3, ROW4};
int col[4] = {COL0, COL1, COL2, COL3};
//--------------------------------------------------------

Main:

#include <keypad.h>
#define ROWS 5
#define COLS 4
keypad kpd = keypad(ROWS, COLS);

void loop(){
char key = kpd.get_key();
Serial.println(key);}

And is done! ;D

Best Regards
Frank