I'm using a standard 3x4 keypad and am able to get the show which key has been entered with the code below.
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 3;
char KeypadData;
//used for 4x4 keypad
// Array to represent keys on keypad
/*
char keys[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
// Connections to Arduino
byte rowPins[ROWS] = {9, 8, 7, 6};
byte colPins[COLS] = {5, 4, 3, 2};
*/
//used for 3x4 krypad
// Array to represent keys on keypad
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
// Connections to Arduino
//byte rowPins[ROWS] = {9, 8, 7, 6};
// Connections to Arduino
byte rowPins[ROWS] = {43, 41, 39, 37}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {31, 33, 35}; //connect to the column pinouts of the keypad
// Create keypad object
Keypad customKeypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
// Setup serial monitor
Serial.begin(115200);
Serial.println("Initialize the Keypad");// Initialize the LCD.
}
void loop() {
KeypadData = customKeypad.getKey();
if (KeypadData) {
Serial.println(KeypadData);
}
}
What I would like is to have the keys numbered 1 through to 12, So if I press the *, 0 , # keys I would like them to display 10, 11, 12 instead.
I've tried to change these variables to a int or byte char keys and char KeypadData but do not get the correct number back.
This is what I've also changed from
//used for 3x4 krypad
// Array to represent keys on keypad
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'*', '0', '#'}
};
to
//used for 3x4 krypad
// Array to represent keys on keypad
char keys[ROWS][COLS] = {
{'1', '2', '3'},
{'4', '5', '6'},
{'7', '8', '9'},
{'10', '11', '12'}
};
But does not work is there away that I can do it ?
Thanks