I have an Arduino Leonardo board successfully passing key presses to my PC from a single 4x3 Key Pad.
Now I need to add a second 4x3 Key Pad.
Here is the code that I have working at present:-
1 #include <Key.h>
2 #include <Keypad.h>
3 #include <Keyboard.h>
4 //Set the number of rows and columns on the keypad
5 const byte ROWS = 4;
6 const byte COLS = 3;
7 //Define which characters are printed when a particular button is pressed on the keypad.
8 //`The characters are laid out just as they appear on the keypad.
9 char hexaKeys[ROWS][COLS] = {
10 {'#', '0', '*'},
11 {'9', '8', '7'},
12 {'6', '5', '4'},
13 {'3', '2', '1'}
14 };
15 byte rowPins[ROWS] = {9, 8, 7, 6};
16 byte colPins[COLS] = {5, 4, 3};
17 Keypad customKeypad = Keypad(makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
18 void setup() { }
19 void loop() {
20 char customKey = customKeypad.getKey();
21 if (customKey) {
22 Keyboard.begin();
23 Keyboard.write(customKey);
24 Keyboard.end();
25 }
26 }
To add a second key pad two issues arise in my mind:-
A) I will have to attach seven more wires to my Leonardo. This means that I will overflow the digital pins and need to use the Analog pins. Will that work?
B) I think that I will need to create a second instance of the function "keypad" in line 17 but I am not sure how to do this. Is there anyone here able to get me started with that?
