// Proof that Keypad library does not have ghosting.
// Using: https://github.com/Chris--A/Keypad
//
// It turned out to be proof that when a button is being pressed,
// an other button on the same row or same column can not
// be detected.
//
#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 3;
// Binary numbers for the keys, this is not common !
char customKeys[ROWS][COLS] =
{
{ 1, 2, 3},
{ 4, 5, 6},
{ 7, 8, 9},
{ 10, 11, 12}
};
byte rowPins[ROWS] = {2, 3, 4, 5};
byte colPins[COLS] = {6, 7, 8};
Keypad kpd = Keypad( makeKeymap(customKeys), rowPins, colPins, ROWS, COLS);
void setup()
{
Serial.begin( 9600);
Serial.println( "The sketch has started");
}
void loop()
{
// The .getKeys() function scans
// all the keys and checks for change.
if( kpd.getKeys())
{
for( int i=1; i<=12; i++)
{
// The .isPressed() function does not check
// the state, but returns a true of that
// key was just pressed.
if( kpd.isPressed(i))
{
Serial.print( "KEY");
Serial.println( i);
}
}
}
}