Professional Documents
Culture Documents
on
BACHELOR OF TECHNOLOGY
In
Electronics & Communication Engineering
By
(11891A0406)
CH. PRAVEEN
( 11891A0407)
(11891A0408)
2011-15
BACHELOR OF TECHNOLOGY
In
Electronics & Communication Engineering
By
(11891A0406)
CH. PRAVEEN
( 11891A0407)
(11891A0408)
2011-15
DECLARATION
We hereby declare that project entitled Digital Code Locking System Using
Arduino Uno is bonafide work duly completed by me/us. It does not contain any part
of the project or thesis submitted by any other candidate to this or any other institute
of the university.
All such materials that have been obtained from other sources have been duly
acknowledged.
CH.SAIPRAVEEN KUMAR
(Regd No.11891A0406 )
CH.PRAVEEN
(Regd No.11891A0407)
CERTIFICATE
This is to certify that the thesis work titled Digital Code Locking System Using Arduino
Uno submitted by CH.SAI PRAVEEN KUMAR(11891A0406), CH.PRAVEEN
(11891A0407),D.SAI VAMSE MOHAN(11891A0408) in partial fulfillment of the
requirements for the award of the degree of Bachelor of Technology in Electronics &
Communication Engineering to the Vignan Institute Of Technology And Science,
Deshmukhi is a record of bonafide work carried out by him/her under my guidance and
supervision.
The results embodied in this project report have not been submitted in any university
for the award of any degree and the results are achieved satisfactorily.
(Assistant Professor)
(External Examinar)
ACKNOWLEDGEMENT
We would like to extend our deepest gratitude to our CEO Mr. Shravan Boyapati and
principle Dr M.Venkata Ramana for his patronage and encouragement.
We also take this opportunity to express our heartfelt thanks to the Head of Department
Mr.N.Dinesh Kumar for his valuable insights and support.
This project has been a great learning experience for our team members for we found
the work very challenging and interesting ,and we experienced as much joy in seeing it
to completion as we had during the design stages.
It goes with out saying that the project would not have seen the light of the day
without the constant guidance and technical knowhow provided by our guide/mentor
Mr.Vikas Kumar Tiwari(Assistant Professor ECE Dept). His willingness to motivate
us contributed tremendously to our project.
Finally we would like to thank the lab authorities and other faculty for obliging us with
their help and guidance whenever sought
ABSTARCT
Security is a prime concern in our daily life. Everyone wants to be as much secure
as possible. So people are using many methods to protect their houses, properties etc.
This project uses a arduino based digital locking system. Here an Arduino
Uno(ATmega328) 16x2 LCD display ,a 4x4 matrix KEYPAD are used. When the
password is entered through the keypad if the password is matched with the stored
password then it gets displayed in lcd saying UNLOCKED .If the passwords do not
match then it displays WRONG PASSWORD AND LOCKED.
Here we use an Arduino Uno (ATmega328) which has 32kb flash memory. It
stores the program which we write & it is erasable i.e whenever we want to set a new
code we can reprogram it. There is keypad through which we can enter the security
code (password). There is an lcd to display the password which we enter.
TABLE OF CONTENTS
Topic
Page no.
Acknowledgement..
Abstract..
ii
Table of contents
iii
List of figures
iv
1. Introduction..
1.1 Overview
3. Block Diagram.
11
3.4 LCD.
12
3.5 KEYPAD.
13
4. Flow chart..
15
5. Hardware Implementation..
17
17
18
19
20
21
7.1 Advantages.
21
7.2 Disadvantages... 22
7
7.3 Applications.. 23
8. Biblography. 24
9. Appendix. 25
LIST OF FIGURES
3.1 BLOCK DIAGRAM. 4
3.2 ARDUINO BOARD.. 6
3.3 PinDiagram of ATmega328.. 11
3.4 Pin Diagram of LCD. 12
3.5 4x4 Matrix Keypad 13
5.1 Interfacing LCD to Arduino 17
5.2 Interfacing 4x4 matrix Keypad to Arduino. 18
5.3 Digital Code Lock Using Arduino.. 19
1. INTRODUCTION
1.1 OVERVIEW:
objective:
Security is a prime concern in our day-today life. Everyone wants to be as much
secure as possible. An access control for doors forms a vital link in a security chain.
The Arduino based digital lock for Doors is an access control system that allows only
authorized persons to access a restricted area. The system is fully controlled by the
ATmega328 microcontroller which 32kb of flash memory . When the entered password
equals with the password stored in the memory then it displays UNLOCKED on the
lcd display.
Digital Security' gives individuals the freedom to embrace the digital lifestyle
confidently engage in everyday interactions across all digital devices. According to
Olivier Piou, CEO of global digital security company .Gemalto, digital security has
a key role to play in the digital revolution. Yet fear of fraud, identity theft, and other
concerns are holding people back from making the most of (what the digital revolution
has to offer). They need to feel that the wealth of devices and services available are
both convenient to use and trustworthy. "Digital security affects all aspects of the digital
lifestyle,
which,
among
others,
comprises
computers
and
the
internet,
the number of contemptible acts like robberies, ransacking and vandalism, the absence
of competent security solutions is an open invitation to trouble. Digital cameras are
extremely useful devices that ensure the safety of your property when you are away at
work on or vacation. With technological advancements you can now implement strong
measures to keep trouble makers away
We have seen the security personnel checking the employees identification cards at
the entrances to avoid illegal entry. The employees sign a register at the entrance before
getting in. This is still being practiced in most of the companies. However, the
disadvantages are that, when there is a necessity of providing control at many locations
inside the company, a person at each point will not be an economical way of
implementing it.
Then came were the punch cards. Employees possess cards, which are punched
when they enter into the building. But it had disadvantages. Workers started to practice
buddy punching, for their co-workers.
Although these techniques are good ,they are time consuming and costly ,so instead of
these we are using a digital lock which has security code so as to prevent the
unauthorized to access. Here we are using Arduino Uno which uses an
ATmega328microcontroller.This microcontroller checks the password 5 digit password
entered then it grants access shown in the lcd display
Arduino Uno R3
Jumper wires
10
2.LITERATURE SURVEY
To underline the work done in this project and to establish acquaintance with the
subject, it is necessary to study the history of the problem statement being investigated
by summarizing aspects of the work that has been done in this regard, both in the past
as well as that which is being pursued now.
11
3. BLOCK DIAGRAM
4x4 MATRIX
INCOMING
CODE
KEYPAD
POWER SUPPLY
ARDUINO UNO
(ATmega328)
(16X2)LCD DISPLAY
12
13
14
Power:
The Arduino Uno can be powered via the USB connection or with an external power
supply. The power source is selected automatically External (non-USB) power can
come either from an AC-to-DC adapter (wall-wart) or battery. The adapter can be
connected by plugging a 2.1mm center-positive plug into the board's power jack. Leads
from a battery can be inserted in the Gnd and Vin pin headers of the POWER connector.
The board can operate on an external supply of 6 to 20 volts. If supplied with less
than 7V, however, the 5V pin may supply less than five volts and the board may be
unstable. If using more than 12V, the voltage regulator may overheat and damage the
board. The recommended range is 7 to 12 volts.
The power pins are as follows:
VIN : The input voltage to the Arduino board when it's using an external power
source (as opposed to 5 volts from the USB connection or other regulated power
source). You can supply voltage through this pin, or, if supplying voltage via
the power jack, access it through this pin.
5V: This pin outputs a regulated 5V from the regulator on the board. The board
can be supplied with power either from the DC power jack (7 - 12V), the USB
connector (5V), or the VIN pin of the board (7-12V). Supplying voltage via the
5V or 3.3V pins bypasses the regulator, and can damage your board. We don't
advise it.
3.3V: A 3.3 volt supply generated by the on-board regulator. Maximum current
draw is 50 mA.
IOREF. This pin on the Arduino board provides the voltage reference with
which the microcontroller operates. A properly configured shield can read the
IOREF pin voltage and select the appropriate power source or enable voltage
translators on the outputs for working with the 5V or 3.3V.
Memory:
15
The ATmega328 has 32 KB (with 0.5 KB used for the bootloader). It also has 2 KB of
SRAM and 1 KB of EEPROM (which can be read and written with the EEPROM
library).
Input and Output pins:
Each of the 14 digital pins on the Uno can be used as an input or output,
using pinmode() ,digital write(), and digital read()functions. They operate at 5 volts.
Each pin can provide or receive a maximum of 40 mA and has an internal pull-up
resistor (disconnected by default) of 20-50 kOhms. In addition, some pins have
specialized functions:
Serial: 0 (RX) and 1 (TX): Used to receive (RX) and transmit (TX) TTL serial data.
These pins are connected to the corresponding pins of the ATmega8U2 USB-to-TTL
Serial chip.
PWM: 3, 5, 6, 9, 10, and 11. Provide 8-bit PWM output with the analog Write
() function.
LED: 13. There is a built-in LED connected to digital pin 13. When the pin is HIGH
value, the LED is on, when the pin is LOW, it's off.
The Uno has 6 analog inputs, labeled A0 through A5, each of which provide 10 bits of
resolution (i.e. 1024 different values). By default they measure from ground to 5
volts, though is it possible to change the upper end of their range using the AREF pin
and the analogReference() function. Additionally, some pins have specialized
functionality:
TWI: A4 or SDA pin and A5 or SCL pin. Support TWI communication using
the Wire Library. There are a couple of other pins on the board:
AREF. Reference voltage for the analog inputs. Used with analogRefernce
()Reset. Bring this line LOW to reset the microcontroller. Typically used to add a
reset button to shields which block the one on the board.
16
Communication:
The Arduino Uno has a number of facilities for communicating with a computer,
another Arduino, or other microcontrollers. The ATmega328 provides UART TTL
(5V) serial communication, which is available on digital pins 0 (RX) and 1 (TX).
An ATmega16U2 on the board channels this serial communication over USB and
appears as a virtual com port to software on the computer. The '16U2 firmware uses the
standard USB COM drivers, and no external driver is needed. However on windows a
.inf file is required. The Arduino software includes a serial monitor which allows simple
textual data to be sent to and from the Arduino board. The RX and TX LEDs on the
board will flash when data is being transmitted via the USB-to-serial chip and USB
connection to the computer (but not for serial communication on pins 0 and 1).
A Software Serial library allows for serial communication on any of the Uno's digital
pins.
The ATmega328 also supports I2C (TWI) and SPI communication. The Arduino
software includes a Wire library to simplify use of the I2C bus; see
the documentation for details. For SPI communication, use the SPI library.
Programming
The Arduino Uno can be programmed with the Arduino software. Select "Arduino
Uno from the Tools > Board menu (according to the microcontroller on your board).
The ATmega328 on the Arduino Uno comes preburned with a boot loader that allows
you to upload new code to it without the use of an external hardware programmer. It
communicates using the original STK500 protocol (reference, C header files).We can
also bypass the boot loader and program the microcontroller through the ICSP (InCircuit
Serial
Programming)
header
using
Arduino
ISP
or
similar.
The ATmega16U2 (or 8U2 in the rev1 and rev2 boards) firmware source code is
available .The ATmega16U2/8U2 is loaded with a DFU bootloader, which can be
activated by:
On Rev1 boards: connecting the solder jumper on the back of the board (near the map
of Italy) and then resetting the 8U2.
17
On Rev2 or later boards: there is a resistor that pulling the 8U2/16U2 HWB line to
ground, making it easier to put into DFU mode.
software (Windows) or the DFU programmer (Mac OS X and Linux) to load a new
firmware. Or you can use the ISP header with an external programmer (overwriting the
DFU boot loader).
Automatic (Software) Reset: Rather than requiring a physical press of the reset
button before an upload, the Arduino Uno is designed in a way that allows it to be
reset by software running on a connected computer. One of the hardware flow control
lines (DTR) of theATmega8U2/16U2 is connected to the reset line of
the ATmega328 via a 100 nano farad capacitor. When this line is asserted (taken low),
the reset line drops long enough to reset the chip. The Arduino software uses this
capability to allow you to upload code by simply pressing the upload button in the
Arduino environment. This means that the bootloader can have a shorter timeout, as
the lowering of DTR can be well-coordinated with the start of the upload.
This setup has other implications. When the Uno is connected to either a computer
running Mac OS X or Linux, it resets each time a connection is made to it from software
(via USB). For the following half-second or so, the bootloader is running on the Uno.
While it is programmed to ignore malformed data (i.e. anything besides an upload of
new code), it will intercept the first few bytes of data sent to the board after a connection
is opened. If a sketch running on the board receives one-time configuration or other
data when it first starts, make sure that the software with which it communicates waits
a second after opening the connection and before sending this data.
The Uno contains a trace that can be cut to disable the auto-reset. The pads on either
side of the trace can be soldered together to re-enable it. It's labeled "RESET-EN". You
may also be able to disable the auto-reset by connecting a 110 ohm resistor from 5V to
the reset line;
USB Overcurrent Protection
The Arduino Uno has a resettable polyfuse that protects your computer's USB ports
from shorts and overcurrent. Although most computers provide their own internal
protection, the fuse provides an extra layer of protection. If more than 500 mA is applied
18
to the USB port, the fuse will automatically break the connection until the short or
overload is removed.
Physical Characteristics
The maximum length and width of the Uno PCB are 2.7 and 2.1 inches respectively,
with the USB connector and power jack extending beyond the former dimension. Four
screw holes allow the board to be attached to a surface or case. Note that the distance
between digital pins 7 and 8 is 160 mil (0.16"), not an even multiple of the 100 mil
spacing of the other pins.
Features of ATmega328:
8-Bit Microcontroller
1K Bytes EEPROM
3.4 LCD
LCD DISPLAY (16x2):
The dot-matrix liquid crystal display controller and driver LSI displays
alphanumeric, characters, and symbols. It can be configured to drive a dotmatrix liquid crystal display under the control of a 4 or 8-bit microprocessor.
Since all the functions such as display RAM, character generator, and liquid
crystal driver, required for driving a dot-matrix liquid crystal display are
internally provided on one chip, a minimal system can be interfaced with this
controller/driver. A single HD44780U can display up to two 8-character lines
(16 x 2).
A 16 x 2 line LCD module is used to display user information.Generally
the lcd can br connected to the Arduino or any microcontroller in two ways.
VLED-
VLED+
DB7
DB6
DB5
DB4
R/W
DB3
RS
DB2
VEE
DB1
VCC
DB 0
VSS
ENABLE
LCD(16x2)
The first way of connecting the LCD is by using only 4 data pins of the lcd .By using
only 4 data pins we can transmit the data from the microcontroller to the lcd i.e the
message or text which we want to display. The second method is by using all the 8 data
pins provided and connecting them to the microcontroller.
C1 - C4
R1-R4
21
The internal arrangement of the keypad is shown below which is nothing but the
interconnection of switches.
There are many methods depending on how you connect your keypad with your
controller, but the basic logic is same. We make the coloums as i/p and we drive the
rows making them o/p, this whole procedure of reading the keyboard is called scanning.
In order to detect which key is pressed from the matrix, we make row lines low one
by one and read the columns. Let us say we first make Row1 low, then read the
columns. If any of the key in row1 is pressed will make the corresponding column as
low i.e if second key is pressed in Row1, then column2 will give low. So we come to
know that key 2 of Row1 is pressed. This is how scanning is done. So to scan the keypad
completely, we need to make rows low one by one and read the columns. If any of the
button is pressed in a row, it will take the corresponding column to a low state which
tells us that a key is pressed in that row. If button 1 of a row is pressed then Column 1
will become low, if button 2 then column2 and so on
22
4. FLOWCHART
START
Initialization of LCD:
4 bt & 2line display
23
Display on LCD
Check the
password
equal
DISPLAY:UNLOCKED
STOP
24
Not equal
Display :WRONG
PASSWORD AND
LOCKED
5. HARDWARE IMPLEMENTATION
5.1 INTERFACING LCD WITH ARDUINO :
In our project we are connecting the lcd display in the 4bit mode i.e we are using
only 4 data pins (DB4,DB5,DB6,DB7) to transmit the information from the controller
to the lcd. The rest of the data pins are not given any connection.
Apart from this we connect the VSS pin to GND, VDD pin to 5v power supply on
the arduino board ,RS pin to digital pin 12 on the arduino board, ENABLE pin to the
digital pin 11on the arduino board and the data pins DB4,DB5,DB6,DB7 to the digital
pins 5,4,3,2 on the arduino respectively.
Circuit diagram:
25
Initally all the columns are made high(input),and all the rows are
madelow(output),whenever a key is pressed the corresponding row and column
becomes low thus a keypress is detected.
26
27
6.1 INTRODUCTION
After the complete system design is completed, the hardware and software is tested for any
connection errors. Once it is clear that the connections are all fine the project working is
tested. Then the Arduino board is powered from the board we can power the lcd so there is no
need of external power supply for LCD
28
7.2 DISADVANTAGE:
The disadvantages are that, when there is a necessity of providing control at many
locations inside the company, a person at each point will not be an economical way of
implementing it.
Then came were the punch cards. Employees possess cards, which are punched
when they enter into the building. But it had disadvantages. Workers started to practice
buddy punching, for their co-workers.
29
7.3 APPLICATIONS:
The term access control refers to the practice of restricting entrance to a
property, a building or a room to authorized persons. Integrated and controller
based access control numeric and alphabetic keyless entry keypads with
programmable features for the access control of single openings. The various
applications are as follows.
Industrial facilities
Commercial buildings
Airports, civil transportation
Convention halls
Psychiatric care centres
Museums and fine art galleries
Ware houses
Technology centres
Government and military
Long term care facilities
Drug rehabilitation centres
30
BIBILOGRAPHY
REFERENCE BOOKS
WEBSITES:
http://arduino.cc/en/Tutorial/LiquidCrystal
http://playground.arduino.cc/Code/Library
http://www.instructables.com/id/password-Lock-with-Arduino
http://www.circuitstoday.com/digital-code-lock-using-arduino
31
APPENDIX
CODE FOR DIGITAL CODE LOCK USING ARDUINO :
#include<LiquidCrystal.h>
LiquidCrystal lcd(7,6,5,4,3,2);
int row[]={A1,A0,8,9};// Defining row pins of keypad connected to Arduino pins
int col[]={10,11,12,13};//Defining column pins of keypad connected to Arduino
int i,j,lcd_count,count=1,key_id=0,flag,entry=0;// See About the Program
int col_scan;// Variable to identify a key press
char temp_press; // Variable to hold value of key press
char check[6],pass[6]; // See About the Program
void setup()
{
lcd.begin(16,2);
for(i=0;i<=3;i++)
{
pinMode(row[i],OUTPUT);
pinMode(col[i],INPUT);
digitalWrite(col[i],HIGH);
}
lcd.print("SET 5 Digit PASS");
}
void loop()
{
while(entry<=4)// Password Setting Loop begins
{
32
SetPassword();
}
// Password Setting Loop Ends
key_id=0;
keyscan(); // Scan for a Key Press
if(temp_press=='A')
{
checkPassword();
if(flag==0)
{
lcd.setCursor(0,0);
lcd.print("UNLOCKED");
}else{
lcd.setCursor(0,0);
lcd.print("WRONG PASSWORD");
delay(200);
lcd.clear();
lcd.print("LOCKED");
}
33
else if(temp_press=='C')
{
checkPassword();
if(flag==0)
{
lcd.setCursor(0,0);
lcd.print("ENTER NEW PASS");
key_id=0;
entry=0;
}else{
lcd.setCursor(0,0);
lcd.print("WRONG PASSWORD");
}
count=1; // Resetting the counter variable
}
else if(temp_press=='B')
{
lcd.setCursor(0,0);
lcd.print("LOCKED");
34
{
pass[entry]=temp_press;
}
}
key_id=0;
35
if(entry==5)
{
lcd.clear();
lcd.setCursor(0,0);
lcd.print("PASSWORD SET & LOCKED");
}} // Subroutine to SET Password ENDS
delay(300);
break;
}}
}}// Subroutine to Scan Keypress Ends
if(i==1&&j==2)
{
return('6');
}
if(i==1&&j==3)
{
return('B');
}
if(i==2&&j==0)
{
return('7');
}
if(i==2&&j==1)
{
return('8');
}
if(i==2&&j==2)
{
return('9');
}
if(i==2&&j==3)
{
return('C');
}
if(i==3&&j==0)
{
return('*');
}
if(i==3&&j==1)
{
return('0');
38
}
if(i==3&&j==2)
{
return('#');
}
if(i==3&&j==3)
{
return('D');
}
} // Subroutine to identify Keypress Ends
void checkPassword() // Subroutine to Check User Input Data with SET Password
{
flag=0;
for(i=1;i<=5&&flag==0;i++)
{
if(check[i]==pass[i])
{
flag=0;
}
else
{flag=1;
}}} // Subroutine to check password ends
39