ESD Lab Project Report
ESD Lab Project Report
Miniproject report on
PassSecure: A Microcontroller-
Based Password Detection System
with LPC 1768
Submitted by
220953310 Soham Bose
220953332 Arjyabir Chatterjee
220953344 Shravani Bhor
Department of I & CT
MIT, Manipal
November, 2024
ABSTRACT
The project aims to develop and implement a password detection system using the LPC1768
microcontroller interfaced with a keyboard, LEDs, and an LCD display. Input through the
keyboard needs to be checked against a previously defined password stored inside the system. If
successful, the LCD shows "Access Granted," with an LED pattern indicating success. If the
password verification fails, a red LED will light up. It combines real-time input handling with a
visual display to meet a simple and effective security mechanism.
Contents:
I. Abstract 3
IV. Introduction 6
V. Methodology 7
VII. References 17
With the increasing demand for heightened security across various applications, open-the-key
password-based access control systems have, by and large, evolved into a simplistic yet
effective solution. The project focuses on the development of a microcontroller-based system
using LPC1768 for implementing the mechanism to manage secure user access via a
password. Through the use of a keyboard for input, an LCD for feedback, and LEDs for
visual feedback, this system provides a robust means for authenticating users.
When a user enters the password, it compares against a pre-set password in the internal
memory of the system. The system then provides access through displaying on the LCD and
sequential operation of two LEDs. If the password does not match, it will give a denial
message and lit another pattern of LEDs. Apart from the combination of instant feedback and
direct feedback using LEDs ensures that these access control solutions are user friendly and
yet very specific in nature in the application even in offices, homes, or restricted areas.
Methodology:
LCD Display: The LCD display serves as the primary visual feedback mechanism for
the user. Typically, a 16x2 character LCD is used, where two or four lines of text can be
displayed. The LCD is controlled by the LPC1768 to show messages such as "Access
Granted" or "Access Denied," based on the outcome of the password comparison. The
LCD operates in 4-bit or 8-bit mode and is connected to the GPIO pins of the
microcontroller.
LED Lights: LEDs are used as visual indicators in the system. A green LED or a
specific LED pattern will indicate successful authentication, while a red LED or another
distinct pattern will indicate failure. The LPC1768 controls the LEDs via its GPIO pins,
triggering specific lighting sequences upon receiving the result of the password check.
Keyboard: The keyboard serves as the input device for the user to enter the password.
Typically, a 4x4 matrix keypad is used, which consists of 16 keys arranged in rows and
columns. The LPC1768 scans the keypad and reads the entered keys. The
microcontroller processes the input to compare it with the pre-defined password,
handling debouncing and keypress recognition through its GPIO or ADC interface.
Reset Switch: The reset switch is used to clear the previously entered password or
restart the password entry process if the user wishes to start over. When pressed, the
switch sends a signal to the microcontroller, resetting the input buffer and allowing the
user to re-enter the password. This switch is connected to an interrupt pin or a GPIO pin
on the LPC1768 and plays a crucial role in ensuring smooth operation and
flexibility for the user.
Working Principle:
3. Keyboard Scanning
The system performs keyboard scanning to detect key presses. The keyboard
matrix uses a 4x4 configuration, and the code maps the scanned input to the
appropriate character.
6. Real-Time Feedback
The system provides real-time feedback during the password entry process.
As each key is pressed, the entered digit is displayed on the LCD.
After the fourth digit, the system instantly provides a result (access granted or
denied) and the corresponding LED pattern is executed.
1) LCD Connections
Data Lines (P0.23 - P0.26): The LCD uses a 4-bit data mode, where data lines D4 to
D7 on the LCD are connected to GPIO pins P0.23 to P0.26 of the LPC1768.
Control Lines:
o RS (Register Select) - P0.27: Connected to the RS pin on the LCD, this line
distinguishes between command mode (RS=0) and data mode (RS=1).
o EN (Enable) - P0.28: Connected to the Enable pin on the LCD. This line pulses
high to latch the data into the LCD.
2) 4x4 Keypad Connections
Row Connections (P2.10 - P2.13): Rows of the keypad are connected to P2.10 to P2.13
on GPIO2. These are configured as outputs. The program cycles through each row by
setting one of these pins high at a time, enabling the row for keypress detection.
Column Connections (P1.23 - P1.26): Columns of the keypad are connected to P1.23
to P1.26 on GPIO1, configured as inputs. When a key is pressed, the corresponding row
and column form a connection, allowing the program to detect which key was pressed.
3) LED Connections
LEDs (P0.4 - P0.11): Eight LEDs are connected to GPIO0 pins P0.4 to P0.11. These
LEDs are controlled in a sequence to indicate a successful password entry. After a
correct password entry, LEDs turn on sequentially and then off in a loop pattern to
signal access granted.
Success Indication (LED Pattern): If the password is correct, the LEDs light up one
by one, then turn off in the same sequence, giving a clear indication of a successful
password attempt.
The LCD, keypad, and LEDs require power and ground connections. The LPC1768
provides regulated power output for these components.
Ensure all modules (LCD, keypad, LEDs) share a common ground with the
microcontroller to establish proper current flow and avoid any potential grounding
issues.
d) Method
1. Initialization Phase
LCD Initialization: The LCD is configured in 4-bit mode by setting up GPIO pins as
outputs for data and control lines. Initialization commands are sent to set the display
mode, clear the screen, and prepare it for displaying characters.
Keypad Configuration: Rows of the keypad are set as outputs and columns as inputs to
allow scanning of keypresses. The keypad uses a 4x4 matrix configuration.
LED Setup: GPIO pins connected to the LEDs are configured as outputs. These LEDs
will be used for feedback based on password correctness.
The LCD displays the prompt "Enter Password:" to inform the user to start entering a
password. This prompt is shown on the first line of the LCD screen.
Scanning the Keypad: The program continuously cycles through each row of the
keypad, setting one row high at a time. When a key is pressed, a connection is made
between the row and a column, which the microcontroller detects.
Key Mapping: Once a key is detected, it is mapped to a corresponding ASCII character
(0-9, +, -, =, D, E, F) using predefined arrays. The program only accepts numeric keys
(0-9) for password input.
Storing Input: The pressed key’s numeric value is stored in an inputPassword array up
to four digits. Each entered digit is displayed on the LCD for user feedback.
4. Password Verification
Once four digits are entered, the program checks the input against the predefined
password stored in the password array.
Comparison Function: The checkPassword function compares the inputPassword array
with the password array:
o If all four digits match, the password is correct.
o If any digit is incorrect, the password is deemed incorrect.
Correct Password:
o The LCD displays "Access Granted."
o The LEDSuccess function is called, triggering a sequential LED pattern as a
success indicator. Each LED lights up one after the other, then turns off in the
same order.
Incorrect Password:
o The LCD displays "Access Denied."
o The LEDFail function is called, which does not trigger any LEDs, providing a
clear indication of failure.
#include <LPC17xx.h>
#include <stdio.h> // For sprintf
unsigned char row, var, flag, key, disp[3]; // Key for showing pressed Key, Disp
for Displaying it with \0
unsigned long int i, j, var1, temp, temp1, temp2, temp3;
unsigned long LED = 0x00000010; // For LED Initial Setting
unsigned char debugBuffer[20];
unsigned char SCAN_CODE[16] = {0x11, 0x21, 0x41, 0x81, // Keyboard Initialization
0x12, 0x22, 0x42, 0x82,
0x14, 0x24, 0x44, 0x84,
0x18, 0x28, 0x48, 0x88};
unsigned char ASCII_CODE[16] = {'0', '1', '2', '3', // Corresponding Buttons for
Keyboard
'4', '5', '6', '7',
'8', '9', '+', '-',
'=', 'D', 'E', 'F'};
// LCD Functions
void Clear_Ports(void)
{
LPC_GPIO0->FIOCLR = 0x0F << 23; // Clearing Data lines
LPC_GPIO0->FIOCLR = 1 << 27; // Clearing RS line
LPC_GPIO0->FIOCLR = 1 << 28; // Clearing Enable line
return;
}
void LCD_ComData(int temp1, int type) // 4 Bit Mode LCD, so necessary shifts
required for sending Commands/Data
{
int temp2 = temp1 & 0xf0;
temp2 = temp2 << 19;
Write(temp2, type);
Delay_LCD(10000);
return;
}
void LCD_Init()
{
LPC_PINCON->PINSEL1 &= 0xFC003FFF; // P0.23 to P0.28 as GPIO
LPC_GPIO0->FIODIR |= 0x0F << 23 | 1 << 27 | 1 << 28; // Setting above bits as
Output
Clear_Ports();
Delay_LCD(32000);
void LEDSuccess(void) // LED Must Serially Turn ON and OFF for showing
Successful Password Attempt
{
LPC_PINCON->PINSEL0 &= 0xFF0000FF; // GPIO and Output Initialization
LPC_GPIO0->FIODIR |= 0x00000FF0;
while(1)
{
LED = 0x00000010;
for(i = 1; i < 9; i++) // ON LEDs serially (8 times)
{
LPC_GPIO0->FIOSET = LED; // Set LED at LSB as High (on)
for(j = 0; j < 1000; j++);
LED <<= 1; // Shift to next LED
}
LED = 0x00000010;
for(i = 1; i < 9; i++) // OFF LEDs serially
{
LPC_GPIO0->FIOCLR = LED; // Set LED at LSB as Low (off)
for(j = 0; j < 5000; j++);
LED <<= 1; // Shift to next LED
}
}
}
void LEDFail(void) // LED Should Not Glow for Unsuccessful Password Attempt
{
// No LED activity; just return.
return;
}
int main(void)
{
int inputPassword[4] = {0}; // Clear input array at start
int passwordIndex = 0; // For checking index
Clear_Ports();
Delay_LCD(32000);
LCD_Init();
while (1)
{
while (passwordIndex < 4)
{
for (row = 1; row < 5; row++)
{
if (row == 1)
var1 = 1 << 10;
else if (row == 2)
var1 = 1 << 11;
else if (row == 3)
var1 = 1 << 12;
else if (row == 4)
var1 = 1 << 13;
temp = var1;
LPC_GPIO2->FIOCLR = 0x3C00; // Clear Port and send Value for Enabling
Row
LPC_GPIO2->FIOSET = var1; // Enabling the Row
flag = 0;
scan(); // Check if any key pressed in Enabled Row
if (flag == 1) // If Pressed
{
break;
}
}
if (flag == 1)
{
for (i = 0; i < 16; i++) // Get Corresponding Letter / Digit to Display
{
if (key == SCAN_CODE[i])
{
key = ASCII_CODE[i];
// Store only if the key is a valid digit
if (key >= '0' && key <= '9' && passwordIndex < 4) {
inputPassword[passwordIndex++] = key - '0'; // Store as integer