/*
Demonstrate a basic matrix
Diodes : no
Ghosting : limited
https://wokwi.com/projects/400921600619685889
https://github.com/Chris--A/Keypad/blob/master/examples/MultiKey/MultiKey.ino
*/
#include <Keypad.h>
const byte ROWS = 5;
const byte COLS = 5;
byte rowPins[ROWS] = {2,3,4,5,6};
byte colPins[COLS] = {8,9,10,11,12};
char customKeys[ROWS][COLS] =
{
{ 'q',NO_KEY,'d','v',NO_KEY},
{ NO_KEY,'w',NO_KEY,'f','b'},
{ 'a','x',NO_KEY,'r',NO_KEY},
{ NO_KEY,'s','c',NO_KEY,'t'},
{ 'z',NO_KEY,'e',NO_KEY,'g'}
};
Keypad kpd = Keypad( makeKeymap(customKeys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
Serial.print("listening...");
}
void loop() {
if (kpd.getKeys())
{
for (int i=0; i<LIST_MAX; i++) // Scan the whole key list.
{
if ( kpd.key[i].stateChanged ) // Only find keys that have changed state.
{
switch (kpd.key[i].kstate) { // Report active key state : IDLE, PRESSED, HOLD, or RELEASED
case PRESSED:
if(kpd.key[i].kchar != NO_KEY){
Serial.print(kpd.key[i].kchar);
}
}
}
}
}
} // End loop