#include <Keypad.h>
const uint8_t ROWS = 4;
const uint8_t COLS = 5;
char keys[ROWS][COLS] = {
{ '1', '2', '3', '4', 'G'},
{ '5', '6', '7', '8', 'H'},
{ '9', '0', 'A', 'B', 'J'},
{ 'C', 'D', 'E', 'F', 'K'}
};
uint8_t colPins[COLS] = {12,11,10,9,8}; // C1–C4
uint8_t rowPins[ROWS] = {4,5,6,7}; // R1–R4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
}
void loop() {
if (keypad.getKeys()) {
for (int i = 0; i < LIST_MAX; i++) {
if (keypad.key[i].stateChanged && keypad.key[i].kstate == PRESSED) {
char k = keypad.key[i].kchar;
int row = keypad.key[i].kcode / COLS;
int col = keypad.key[i].kcode % COLS;
Serial.print("Tuş = ");
Serial.print(k);
Serial.print(" | RowPin = ");
Serial.print(rowPins[row]);
Serial.print(" | ColPin = ");
Serial.println(colPins[col]);
}
}
}
}
/*
#include <Keypad.h>
const uint8_t ROWS = 4;
const uint8_t COLS = 5;
char keys[ROWS][COLS] = {
{ '1', '2', '3', 'A' },
{ '4', '5', '6', 'B' },
{ '7', '8', '9', 'C' },
{ '*', '0', '#', 'D' }
};
uint8_t colPins[COLS] = { 5, 4, 11, 10 }; // Pins connected to C1, C2, C3, C4
uint8_t rowPins[ROWS] = { 9, 8, 7, 6 }; // Pins connected to R1, R2, R3, R4
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
void setup() {
Serial.begin(9600);
}
void loop() {
char key = keypad.getKey();
if (key != NO_KEY) {
Serial.print("düğme=");
Serial.println(key);
}
}
*/