#include <Arduino.h>
#include <U8g2lib.h> // u8g2 library is used to draw graphics on the OLED display
#include <Wire.h> // library required for I2C communication
#include <U8glib.h>
#include <Keypad.h>
// Define the size of the keypad
const byte ROWS = 3;
const byte COLS = 4;
// Define the key map
const char keys[ROWS][COLS] =
{
{'A','B','C','D'},
{'E','F','G','H'},
{'I','J','K','L'},
};
// Connect keypad rows and columns to Arduino pins
byte rowPins[ROWS] = {13, 12, 11};
byte colPins[COLS] = {10, 9, 8, 7};
// Create keypad object
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS);
// Connect LEDs
byte LED_PINS[] = {6, 5, 4, 3};
const byte LED_PIN_COUNT = sizeof(LED_PINS);
//led[A] = {5,6};
//led[B] = {6,5};
//led[C] = {4,6};
// led[D] = {6,4};
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
char key = keypad.getKey(); // Get key press
if (key) {
Serial.print("Pressed Key: ");
Serial.println(key);
}
for (byte i = 0; i < LED_PIN_COUNT; i++) {
for (byte j = 0; j < LED_PIN_COUNT; j++) {
if (i != j) {
pinMode(LED_PINS[i], OUTPUT);
pinMode(LED_PINS[j], OUTPUT);
digitalWrite(LED_PINS[i], LOW);
digitalWrite(LED_PINS[j], HIGH);
delay(50);
pinMode(LED_PINS[i], INPUT);
pinMode(LED_PINS[j], INPUT);
}
}
}
}