Hey there. I'm trying to make a keyboard using a 16 key keypad. (yes that sounds stupid i know) and the varible for keeping track of my F1 - F4 keys wont update.
#include <Key.h>
#include <Keypad.h>
//keypad
const byte ROWS = 4;
const byte COLS = 4;
byte rowPins[ROWS] = {5, 4, 3, 2};
byte colPins[COLS] = {6, 7, 8, 9};
int currentKey = 1;
char commands[ROWS][COLS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'F1', 'F2', 'F3', 'F4'}
};
Keypad MyPad_command = Keypad(makeKeymap(commands), rowPins, colPins, ROWS, COLS);
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
if (currentKey == 1 ) {
char result = MyPad_command.getKey();
if (result == "F2") {
currentKey = 2;
} else if (result == "F3") {
currentKey = 3;
} else if (result == "F4") {
currentKey = 4;
} else {
if (result) {
Serial.print(result);
Serial.print(" current Key: ");
Serial.println(currentKey);
}
}
}
}
if F2 - F4 are pushed, the code should stop registering key presses, but that doesnt happen...