#include <Keypad.h>
const byte Rows=4;
const byte Cols=4;
char hexaKeys[Rows][Cols]={
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowpins[Rows]={9,8,7,6};
byte colpins[Rows]={5,4,3,2};
Keypad customkeypad=Keypad(makeKeymap(hexaKeys),rowpins,colpins,Rows,Cols);
char customkey;
int led=10;
void setup() {
Serial.begin(9600);
pinMode(led, OUTPUT);
}
void loop() {
customkey=customkeypad.getKey();
if(customkey!=NO_KEY)
{
Serial.println(customkey);
switch(customkey){
case'1':
digitalWrite(led, HIGH);
break;
case'2':
digitalWrite(led, LOW);
break;
default:;
}
}
}