/*
author : Rajeev TR
date : 04/09/2024
https://github.com/HoNtErBoT
*/
#include <Keypad.h>
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x27,16,2);
// Define the number of rows and columns on the keypad
const byte ROWS = 4;
const byte COLS = 4;
int Pass_len=5;
String myPass="369AB";
String userPass;
String lcdPass;
String hidePass;
char key;
// Define the keymap for your keypad
char keys[ROWS][COLS] =
{
{'1','2','3','A'},
{'4','5','6','B'},
{'7','8','9','C'},
{'*','0','#','D'}
};
byte rowPins[ROWS] = {2, 3, 4, 5}; // Connect keypad ROW0, ROW1, ROW2, ROW3 to Arduino pins 2, 3, 4, 5
byte colPins[COLS] = {6, 7, 8, 9}; // Connect keypad COL0, COL1, COL2, COL3 to Arduino pins 6, 7, 8, 9
Keypad keypad = Keypad(makeKeymap(keys), rowPins, colPins, ROWS, COLS); // Create the Keypad object
void setup()
{
lcd.begin(16,2);
lcd.clear();
lcd.print("Enter password");
lcd.setCursor(0, 0);
}
void loop()
{
int i=0;
key = keypad.getKey(); // Read the key
if (key)
{
if(key!='#')
userPass +=key;
hidePass+=key;
lcd.clear();
lcd.print(hidePass);
lcd.setCursor(0, 1);
delay(300);
lcd.clear();
lcdPass +='*';
hidePass=lcdPass;
lcd.print(lcdPass);
lcd.setCursor(0, 1);
}
if(key=='#')
{
if(userPass==myPass)
{
lcd.clear();
lcd.print("Correct");
lcd.setCursor(0, 0);
}
else
{
lcd.clear();
lcd.print("Incorrect");
lcd.setCursor(0, 1);
userPass="";
lcdPass="";
hidePass="";
delay(2500);
lcd.clear();
lcd.print("Enter password");
lcd.setCursor(0,1);
}
}
}