#include <Keypad.h>
const int LED_PINS[] = {2, 3, 4, 5, 6, 7, 8, 9}; // LED'lerin bağlı olduğu pinler
const byte ROW_NUM = 4; // Keypad'in satır sayısı
const byte COLUMN_NUM = 4; // Keypad'in sütun sayısı
char keys[ROW_NUM][COLUMN_NUM] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte pin_rows[ROW_NUM] = {13, 12, 11, 10}; // Keypad'in satır pinleri
byte pin_column[COLUMN_NUM] = {9, 8, 7, 6}; // Keypad'in sütun pinleri
Keypad keypad = Keypad(makeKeymap(keys), pin_rows, pin_column, ROW_NUM, COLUMN_NUM);
int currentLED = 0; // Mevcut LED'in dizin değeri
void setup() {
for (int i = 0; i < 8; i++) {
pinMode(LED_PINS[i], OUTPUT);
}
}
void loop() {
char key = keypad.getKey(); // Keypad'ten tuşu oku
if (key != NO_KEY) {
// Eğer tuş basıldıysa
if (key == 'A') {
currentLED++;
if (currentLED >9) {
currentLED = 0;
}
} else if (key == 'B') {
currentLED--;
if (currentLED < 0) {
currentLED = 9;
}
}
// LED'leri güncelle
updateLEDs();
}
}
void updateLEDs() {
for (int i = 0; i < 8; i++) {
if (i == currentLED) {
digitalWrite(LED_PINS[i], HIGH); // Mevcut LED'i yak
} else {
digitalWrite(LED_PINS[i], LOW); // Diğer LED'leri söndür
}
}
}