#include <Keypad.h>
int load = 11;
int clockEnablePin = 12;
int dataIn = 9;//q7
int clockIn = 10;
// Define the number of columns and rows in the keypad
#define NUM_COLUMNS 4
#define NUM_ROWS 4
// Define the keypad keys
char keys[NUM_ROWS][NUM_COLUMNS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
// Define the keymap
char keymap[NUM_ROWS][NUM_COLUMNS] = {
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
// Create a Keypad object
Keypad keypad = Keypad(makeKeymap(keymap), rowPins, colPins, NUM_ROWS, NUM_COLUMNS);
// Create a ShiftIn object for the shift register
ShiftIn<4, MSBFIRST> shift(dataIn, clockIn, load);
void setup() {
// put your setup code here, to run once:
pinMode(load, OUTPUT);
pinMode(clockEnablePin, OUTPUT);
pinMode(clockIn, OUTPUT);
pinMode(dataIn, INPUT);
}
void loop() {
// Read the state of the keypad using the shift register
uint16_t data = shift.read();
// Use the Keypad library to get the key pressed
char key = keypad.getKey();
if (key != NO_KEY) {
Serial.println(key);
}
// Delay for stability
delay(100);
}