#include <Keypad.h>
#define LED 5
const byte ROWS = 4; //four rows
const byte COLS = 3; //three columns
char keys[ROWS][COLS] = {
{'1','2','3'},
{'4','5','6'},
{'7','8','9'},
{'*','0','#'}
};
byte rowPins[ROWS] = {6,7,8,9}; // Pins connected to R1, R2, R3, R4
byte colPins[COLS] = {10,11,12}; // Pins connected to C1, C2, C3
Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );
void setup()
{
Serial.begin(9600);
pinMode(LED,OUTPUT);
}
void loop()
{
char key = keypad.getKey();
if (key)
{
Serial.println(key);
digitalWrite(LED,HIGH);delay(200);
digitalWrite(LED,LOW);
}
}