0% found this document useful (0 votes)
8 views3 pages

Bunquin Keypad

Uploaded by

Orven Mendoza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

Bunquin Keypad

Uploaded by

Orven Mendoza
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Bunquin Josh Antonio D.

BSCPE – 3A
SCHEMATIC DIAGRAM
CODE :
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27, 16, 2); // set the LCD address to 0x27 for a
16 chars and 2 line display
String pad;
const byte numRows = 4;
const byte numCols = 4;
String password = "BCD9";
char keypressed;
char keymap[numRows][numCols] =
{
{'1', '2', '3', 'A'},
{'4', '5', '6', 'B'},
{'7', '8', '9', 'C'},
{'*', '0', '#', 'D'}
};
//------------------------------------------------------------
byte rowPins[numRows] = {10, 9, 8, 7};
byte colPins[numCols] = {6, 5, 4, 3};
Keypad myKeypad = Keypad(makeKeymap(keymap), rowPins, colPins, numRows,
numCols); //mapping keypad
void setup() {
lcd.begin();
lcd.backlight();
lcd.setCursor(0, 0);
lcd.print("Keypad");
lcd.setCursor(0, 1);
lcd.print("Test");
delay(1000);
lcd.clear();
}
void loop() {
// put your main code here, to run repeatedly:
readKeypad();
if (keypressed == '#') {
if (pad == password) {
lcd.setCursor(0, 1);
lcd.print("Access Granted");
} else {
lcd.setCursor(0, 1);
lcd.print("Access Denied");
}
} if (keypressed == '*') {
pad = "";
lcd.clear();
}
lcd.setCursor(0, 0);
lcd.print(pad);
delay(100);
}
void readKeypad() {
keypressed = myKeypad.getKey(); //deteksi penekanan keypad
if (keypressed != '#') {
String konv = String(keypressed);
pad += konv;
}
}

You might also like