0% found this document useful (0 votes)
34 views

ESD Lab Project Report

Uploaded by

shravanibhor3084
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views

ESD Lab Project Report

Uploaded by

shravanibhor3084
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 24

ICT 3143 Embedded Systems lab

Vth Sem B.Tech (CCE)

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

II. List of Figures 5

III. List of Tables 6

IV. Introduction 6

V. Methodology 7

VI. Results and Discussion 12

VII. References 17

VIII. C code with comments 18

IX. Similarity Index Report 22


List of Figures

Fig1: LPC 1768 microcontroller


Fig2: Arm Development board with LCD and LEDs
Fig3: 4x4 Matrix Keyboard
Fig4: Matrix Keyboard Circuit Diagram
Fig5: Password Detector System with LPC1768 Microcontroller
Fig6: Circuit Diagram for Password Detector System with LPC1768 Microcontroller
Fig7: LPC1768 Microcontroller
Fig8: LPC1768 Microcontroller
Fig9: LPC1768 Microcontroller
Fig10: LPC1768 Microcontroller
Fig11: LPC1768 Microcontroller
Introduction:

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:

a) Components Required and working principle of all the components

Components Required for LPC1768-based Password Detector:


 LPC1768 Microcontroller: The LPC1768 is a powerful 32-bit ARM Cortex-M3
microcontroller from NXP, widely used for embedded systems due to its efficiency and
versatile features. In this project, the LPC1768 manages keyboard input, compares
passwords, and controls the LCD and LED output based on the authentication results.

Fig1: LPC 1768 microcontroller

 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.

Fig2: Arm Development board with LCD and LEDs

 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.

Fig3: 4x4 Matrix Keyboard Fig4: Matrix Keyboard Circuit Diagram

 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:

1. Password Input and Detection


 Users can input a password via a keyboard connected to the LPC1768
microcontroller.
 The system compares the entered password with a predefined password stored in
the microcontroller's memory (in the code, the predefined password is {1, 2, 3,
4}).
 The LCD displays "Enter Password" to prompt the user for input.
 As each digit of the password is entered, the corresponding character is
displayed on the LCD in real-time.
2. LED Indication
 When the correct password is entered, a serial LED pattern is displayed, where
the LEDs turn on and off one by one, simulating a "success" sequence.
 When the wrong password is entered, all LEDs blink simultaneously to signal
that the authentication attempt has failed.

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.

4. Modular LCD Handling


The code includes modular functions to control the LCD, such as:
 Initialisation of the LCD (in 4-bit mode).
 Displaying characters or messages (e.g., "Access Granted," "Access Denied").
 Clearing the display when required.

5. Password Reset Mechanism


 Once the password attempt is completed (successful or unsuccessful), the input
password array is reset to allow for a new attempt.

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.

b) Block Diagram, Circuit diagram


Fig5: Block Diagram for Password Detector System with LPC1768 Microcontroller
Fig6: Circuit Diagram for Password Detector System with LPC1768 Microcontroller

c) Description about the connection

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.

4) Power and Ground

 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.

2. Display Prompt on LCD

 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.

3. Password Input via Keypad

 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.

5. Result Display and LED Feedback

 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.

Results and Discussion:


Fig7: The message “Enter Password” is displayed on the LCD
Fig8: User inputs password through 4x4 Matrix Keyboard
Fig9: Password is verified successfully, and access is granted
Fig10: User inputs password through 4x4 Matrix Keyboard once again
Fig11: Access denied because incorrect password is entered
References
[1] Explore Embedded, "Category: LPC1768 Tutorials," Explore Embedded. Accessed: Nov. 5,
2024. [Online]. Available:
https://www.exploreembedded.com/wiki/Category:LPC1768_Tutorials
[2] Electronics Hub, "How to Program GPIO in LPC1768," Electronics Hub. Accessed: Nov. 5,
2024. [Online]. Available: https://www.electronicshub.org/how-to-program-gpio-in-lpc1768/
C code with comments:

#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'};

int password[4] = {1, 2, 3, 4}; // Write / Change Password here

// LCD Functions

void Delay_LCD(unsigned int r1)


{
unsigned int r;
for (r = 0; r < r1; r++);
return;
}

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 Write(int temp2, int type)


{
Clear_Ports();
LPC_GPIO0->FIOPIN = temp2; // Assign the value to the data lines
if (type == 0)
LPC_GPIO0->FIOCLR = 1 << 27; // Clear bit RS for Command
else
LPC_GPIO0->FIOSET = 1 << 27; // Set bit RS for Data
LPC_GPIO0->FIOSET = 1 << 28; // Pulse EN Bit
Delay_LCD(10000);
LPC_GPIO0->FIOCLR = 1 << 28;
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);

temp2 = temp1 & 0x0f;


temp2 = temp2 << 23;
Write(temp2, type);

Delay_LCD(10000);
return;
}

void LCD_Puts(unsigned char *buf1) // Function for displaying on LCD


{
unsigned int i = 0;
unsigned int temp3;
while (buf1[i] != '\0')
{
temp3 = buf1[i];
LCD_ComData(temp3, 1);
i++;
if (i == 16)
{
LCD_ComData(0xC0, 0); // Go to next Line
}
}
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);

// LCD Startup Functions


LCD_ComData(0x33, 0); // 4 Bit Mode Initialization
Delay_LCD(300000);
LCD_ComData(0x32, 0);
Delay_LCD(300000);
LCD_ComData(0x28, 0); // Function Set
Delay_LCD(300000);
LCD_ComData(0x0c, 0); // Display ON Cursor OFF
Delay_LCD(80000);
LCD_ComData(0x06, 0); // Entry Mode Set, Increment Cursor right
Delay_LCD(800);
LCD_ComData(0x01, 0); // Display Clear
Delay_LCD(100000);
return;
}

void scan(void) // Checking for Key Press


{
temp3 = LPC_GPIO1->FIOPIN;
temp3 &= 0x07800000; // Check bits 23 to 26 for enabled row
if (temp3 != 0)
{
flag = 1;
temp3 >>= 19; // Shifted to come to Higher Nibble
temp >>= 10; // Shifted to come to Lower Nibble
key = temp3 | temp; // Get SCAN_CODE (0 to 7 bits)
}
}

int checkPassword(int input[])


{
unsigned int i;
for (i = 0; i < 4; ++i)
{
if (input[i] != password[i]) // If any digit not matching,
return 0; // Incorrect password, return False
}
return 1; // Else Correct password, return True
}

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

LPC_GPIO2->FIODIR |= 0x3C00; // Make Output P2.10 to P2.13 (Rows)


LPC_GPIO1->FIODIR &= 0xF87FFFFF; // Make Input P1.23 to P1.26 (Cols)

LPC_GPIO0->FIODIR |= 0x0F << 23 | 1 << 27 | 1 << 28; // LCD Initialization

Clear_Ports();
Delay_LCD(32000);

LCD_Init();

LCD_ComData(0x80, 0); // Point to First Line of LCD


Delay_LCD(80000);
LCD_Puts("Enter Password:"); // Print Enter Password in first line

LCD_ComData(0xC0, 0); // Point to Next Line of LCD


Delay_LCD(800);

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

// Clear the LCD and show current input


LCD_ComData(0x01, 0); // Clear Display
Delay_LCD(80000);

// Display the entered digit


disp[0] = key;
disp[1] = '\0'; // Null-terminate for display
LCD_Puts(disp); // Displaying Pressed Key
Delay_LCD(200000); // Adjust this value for longer display

// Display current input for debugging


sprintf(debugBuffer, "Input: %d%d%d%d", inputPassword[0],
inputPassword[1], inputPassword[2], inputPassword[3]);
LCD_ComData(0xC0, 0); // Move to second line
LCD_Puts(debugBuffer); // Display current input
Delay_LCD(50000000); // Longer delay for user to see the input
}
break;
}
}
}
}

LCD_ComData(0x01, 0); // Clear Display


Delay_LCD(80000);

if (checkPassword(inputPassword)) // Check with Defined Password and print


required Message and LED Pattern
{
LCD_Puts("Access Granted");
LEDSuccess();
}
else
{
LCD_Puts("Access Denied");
LEDFail();
}

passwordIndex = 0; // Reset Variable for Next attempt


for (i = 0; i < 4; i++) {
inputPassword[i] = 0; // Clear input array for the next attempt
}
}
}
Append similarity index report

You might also like