Q.No.8 - Write a program to show which key is press on Keypad.

Sol.-

#include <Keypad.h>
char keys [4] [4] = {
			{'1','2','3','A'},
			{'4','5','6','B'},
			{'7','8','9','C'},
			{'*','0','#','D'}
		     };
byte rowPins[4]={ 9,8,7,6};
byte columnPins[4]={5,4,3,2};
Keypad keypad= Keypad(makeKeymap(keys),rowPins,columnPins,4,4);
void setup()
{
     Serial.begin(9600);
}
void loop()
{
	char key=keypad.getKey();
		if (key)
		     {  Serial.print("You Press:");
              Serial.println(key);}
}

OUTPUT: