Skip to content

Instantly share code, notes, and snippets.

@elktros
Created January 21, 2018 11:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elktros/e30e976f17be843f855aeeee18052d0c to your computer and use it in GitHub Desktop.
Save elktros/e30e976f17be843f855aeeee18052d0c to your computer and use it in GitHub Desktop.
Arduino code for interfacing 4x4 Matrix Keypad with Arduino UNO and displaying the result on 16x2 LCD Display.
#include <Keypad.h>
#include <LiquidCrystal.h>
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char hexaKeys[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {0, 1, 2, 3}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {4, 5, 6, 7}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad customKeypad = Keypad( makeKeymap(hexaKeys), rowPins, colPins, ROWS, COLS);
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
void setup()
{
lcd.begin(16, 2);
lcd.print("Electronics Hub");
delay(2000);
lcd.clear();
lcd.setCursor(0, 0);
}
void loop()
{
char customKey = customKeypad.getKey();
if (customKey)
{
lcd.print(customKey);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment