/* @file CustomKeypad.pde
|| @version 1.0
|| @author Alexander Brevig
|| @contact [email protected]
||
|| @description
|| | Demonstrates changing the keypad size and key values.
|| #
*/
#include <Keypad.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2);
const byte ROWS = 4; //four rows
const byte COLS = 4; //four columns
//define the cymbols on the buttons of the keypads
char keymap[ROWS][COLS] = {
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {9, 8, 7, 6}; //connect to the row pinouts of the keypad
byte colPins[COLS] = {5, 4, 3, 2}; //connect to the column pinouts of the keypad
//initialize an instance of class NewKeypad
Keypad myKeypad = Keypad( makeKeymap(keymap), rowPins, colPins, ROWS, COLS);
void setup(){
Serial.begin(9600);
lcd.begin(16, 2);
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print("Saddam Gusti R");
lcd.setCursor(0,1);
lcd.print("191020100069");
delay(5000);
lcd.clear();
}
void loop(){
lcd.setCursor(2, 0);
lcd.print("Tekan KEYPAD");
char keypressed = myKeypad.getKey();
if (keypressed){
Serial.println(keypressed);
lcd.setCursor(7,1);
lcd.println(keypressed);
}
}