Over the limit

[Arduino] 4x4 matrix keypad로 키보드 만들기 본문

Etc/Arduino

[Arduino] 4x4 matrix keypad로 키보드 만들기

ellapk 2021. 5. 27. 20:26

 

 

 

 

 

 

 

#include <Keypad.h>
const byte ROWS = 4;
const byte COLS = 4;
char hexaKeys[ROWS][COLS] = {
  {'0', '1', '2', '3'},
  {'4', '5', '6', '7'},
  {'8', '9', 'a', 'b'},
  {'c', 'd', 'e', 'f'}
};
byte rowPins[ROWS] = { 6, 7, 8, 9 };
byte colPins[COLS] = {10, 11, 12, 13};
char customKey;
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), 
rowPins, colPins, ROWS, COLS);

void setup() {
  Serial.begin(9600);
}
void keyPress();

void loop() {
  keyPress();
}

void keyPress() {                                 
  customKey = customKeypad.getKey();
  if (customKey) {    
    Serial.println(customKey);
    delay(100);
  }
}