#include<Keypad.h>
#define CLOCK 2
#define LATCH 3
#define DATA 4
int num[] = {252 ,96, 218, 242, 102, 182, 190, 224, 254, 246, 238, 62, 156, 122};
void printNum(int inputKey) {
digitalWrite(LATCH, LOW);
shiftOut(DATA, CLOCK, LSBFIRST, inputKey);
digitalWrite(LATCH, HIGH);
}
char keys[4][4] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
byte rowPins[] = {5, 6, 7, 8};
byte colPins[] = {9, 10, 11, 12};
Keypad myKey = Keypad(makeKeymap(keys), rowPins, colPins, 4, 4);
void setup()
{
pinMode(CLOCK, OUTPUT);
pinMode(LATCH, OUTPUT);
pinMode(DATA, OUTPUT);
Serial.begin(9600);
}
void loop()
{
char inputKey = myKey.getKey();
if (inputKey >= '0' && inputKey <= '9') {
int numIndex = inputKey - '0';
printNum(num[numIndex]);
Serial.println(inputKey);
} else if (inputKey >= 'A' && inputKey <= 'D') {
int numIndex = 10 + (inputKey - 'A');
printNum(num[numIndex]);
Serial.println(inputKey);
}
}