Ammu Internship (1) Merged

Download as pdf or txt
Download as pdf or txt
You are on page 1of 62

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

‘JNANASANGAMA’, BELAGAVI - 590018.

An Internship Report on

Embedded Programming & Interface of 8/16/32 bit Microcontroller

Submitted in partial fulfilment of the requirement for the award of degree of

Bachelor Of Engineering in Electronics and Communication

Submitted By

SUGUNA 1GG20EC039
Internship carried out at
Karnataka German Technical Training Institute,
Manjunath Nagar, Bagalakunte, Bengaluru - 560073

DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING


GOVERNMENT ENGINEERING COLLEGE
B.M. ROAD, RAMANAGARAM-562159
2023-2024.
GOVERNMENT ENGINEERING COLLEGE, RAMANAGARA
DEPARTMENT OF ELECTRONICS AND COMMUNICATION

INTERNSHIP CERTIFICATE

This is to certify that the SUGUNA Bearing USN: 1GG20EC039, a bonafide


student of Government Engineering College, Ramanagara has successfully
completed internship work entitled “Embedded Programming & Interface of
8/16/32 bit Microcontroller” at “KGTTI, BENGALURU”. In partial
fulfilment for the award of Bachelor of Engineering in Electronics and
Communication Engineering of Visvesvaraya Technological University,
Belagavi during academic year 2023-2024. The Internship Report has been
approved as it satisfies the academic requirement in respect of internship work
prescribed for the said degree. Internal Guide.

Internal Guide Head of Department Principal


Dr. Imran Khan Dr. Imran Khan Dr. G Pundarika
Head of Department Head of Department GEC, Ramanagara
Department of ECE Department of ECE

External Viva
Name of the Examiner Signature with Date

1) ………………………………
………………………………

2) ………………………………
………………………………
COMPANY CERTIFICATE
DECLARATION
I, SUGUNA, bearing the USN: 1GG20EC039 a student of 8th semester ,
Electronics and Communication Engineering, Government Engineering College
Ramanagara, hereby declare that the internship Work entitled “Embedded
Programming & Interface of 8/16/32 bit Microcontroller” has been
independently carried out by me under the supervision and the guidance of
Mr. AMIR AHMED Z, KGTTI, Bengaluru and Dr. Imran Khan, Head of
Department, Department of Electronics and Communication Engineering,
GECR, submitted by me as a partial fulfilment of the course requirements of 8th
semester, Bachelor of Engineering in Electronics and Communication
Engineering as prescribed by VISVESVARAYA TECHNOLOGICAL
UNIVERSITY, Belagavi during the academic year 2023-2024.

I also declare that, to the best of my knowledge and belief, the work report here
does not from part of any other report based on which a degree or award was
conferred an earlier occasion on this by any other student.

SUGUNA
(1GG20EC039)
ACKNOWLEDGEMENT
I would like to express my gratitude to Dr. G PUNDARIKA, Principal,
Government Engineering College, Ramanagara for providing me the excellent
facilities and academic ambience which has helped me in satisfactory completion
of this Bachelor’s Degree.

I express my sincere gratitude to Dr. IMRAN KHAN, Head of Department, Dept


of Electronics and Communication Engineering, for his valuable support.

I also express my sincere thanks and heartfelt gratitude to my internal guide and
internship coordinator, Dr. IMRAN KHAN, Head of Department, Department of
Electronics and Communication Engineering, for his inspiring guidance,
throughout the course of the present work. .

I wish to express my heartfelt gratitude to my external guide Mr. AMIR AHMED,


KGTTI, Bengaluru.

Finally, I take this opportunity to thank all my Teaching staffs, non-Teaching


staffs, & friends, who helped me in some technical aspects and last but not the
least I wish to express deepest sense of gratitude to my parents who were a
constant source of encouragement and stood by me as pillar of strength for
completing this work and course successfully.

SUGUNA
(1GG20EC039)
GOVERNMENT ENGINEERING COLLEGE RAMANAGARA
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING

Vision of the Institute


“To become a premier Engineering college by providing quality technical education and
research with professional ethics embedded with human values”

Mission of the Institute


➢ To constantly improve quality of education system that produces engineers having
good technical capabilities with ethical and human values.

➢ To encourage faculty and students to engage in significant research and consultancy


by nurturing a good eco-system

➢ To strengthen industry institute collaboration for promoting team work, internship,


training and entrepreneurship.

➢ To enhance educational opportunities for the students from rural and weaker sections
of the society.

Department Vision

To became centre of excellence in E&C engineering by improving knowledge, relevant


practices and research mindset to produce Global Professionals and Entrepreneurs with ethics
and human values to societal needs.

Department Mission
M1: To inculcate strong fundamentals and technical skills through innovative solutions and
teamwork with ethics and human values to cater to societal needs.
M2: To impart quality education in Electronics & Communication Engineering that bridges
the gap between industry and institute through training, internship and research.
M3: To provide an ambience for quality education and research to the students from rural and
weaker section of society to become Global Professional and Entrepreneurs.

Program Educational Objectives(PEOs)


PEO 1: Graduates apply their knowledge to analysis, design and implement analog and
digital circuits for real time problems.
PEO 2: Graduates exhibit their multidisciplinary innovative skills in management,
programming and develop sophisticated hardware and software systems.
PEO 3: Graduates exhibits professionalism, ethical outlook, effective communication, team
work and engage in lifelong learning process through technical training research.
GOVERNMENT ENGINEERING COLLEGE RAMANAGARA
DEPARTMENT OF ELECTRONICS AND COMMUNICATION ENGINEERING
INTERNSHIP EVALUATION RUBRICS
INTERNSHIP Work Evaluation:
1. All the students admitted to III year of BE/B.Tech shall have to undergo mandatory
internship of 4 weeks during the vacation of VI and VII semesters and /or VII and VIII
semesters. A University examination shall be conducted during VIII semester and the
prescribed credit shall be included in VIII semester.
2. The internship can be carried out in any industry /R and D Organization/Research Institute/
reputed educational institute.
3. Internship shall be considered as a head of passing and shall be considered for the award
of degree. Those, who do not take-up/complete the internship shall be declared fail and
shall have to complete during subsequent University examination after satisfying the
internship requirements.
4. The Department/college shall nominate staff member/s to facilitate, guide and supervise
students under internship. The students shall report the progress of the internship to the
guide in regular intervals and seek his/her advice.
5. After the completion of Internship, students shall submit a report with completion and
attendance certificates to the Head of the Department with the approval of both internal and
external guides.
6. There will be 40 marks for CIE (Report: 20, Presentation: 10 Q & A: 10) and 60 marks
for SEE. The minimum requirement of CIE marks shall be 50% of the maximum marks.
7. The Internship evaluation committee and the internal guide shall award the CIE marks for
internship after evaluation.
8. The external guide from the industry shall be an examiner for the viva voce on Internship.
Viva-Voce on internship shall be conducted at the college and the date of Viva-Voce shall
be fixed in consultation with the external Guide. The Examiners shall jointly award the
Viva- Voce marks. In case the external Guide expresses his inability to conduct viva voce,
the Chief Superintendent of the institution shall appoint a senior faculty of the Department
to conduct viva-voce along with the internal guide. The same shall be informed in writing
to the concerned Chairperson, Board of Examiners (BOE).
9. The students are permitted to carry out the internship anywhere in India or abroad.
Course outcomes:

1. Apply engineering and management principles in solving real time problems at their
workplace.

2. Identify, write down, and carry out performance objectives, optimized solutions
related to their job assignment using modern tools

3. Develop team work, good communication, interpersonal and other critical skills for
job interview process.

4. Develop work habits and practice of professional ethics for lifelong learning.

Program outcomes:
The students gain confidence and meaningful experience in the area of their work during
internships. This learning may be listed by the National Board of Accreditation (NBA) in the areas
of Engineering knowledge (PO1), Individual and team work (PO9) and Lifelong Learning (PO12).

CO-PO Mapping:
No Course Outcome CL Linked POs
Apply engineering and management principles in solving
CO 1 L4 1,2,3,4,5,7
real time problems at their workplace
Identify, write down, and carry out performance objectives,
CO 2 optimized solutions related to their job assignment using L4 1,2,3,4,5,6,7,9,10,11
modern tools
Develop team work, good communication, interpersonal
CO 3 L4 1,2,9,10
and other critical skills for job interview process.
Develop work habits and practice of professional ethics for
CO 4 L4 1,8,12
lifelong learning.

PO 1 PO 2 PO 3 PO 4 PO 5 PO 6 PO 7 PO 8 PO PO PO PO PSO PSO
9 10 11 12 1 2
CO 1 3 2 2 2 2 - 1 - - - - - 3 -

CO 2 3 2 2 2 2 2 2 - 2 3 2 - 3 3

CO 3 3 2 - - - - - - 2 3 - - - -

CO 4 3 - - - - - - 3 - - - 3 3 -
RUBRICS FOR INTERNSHIP PRACTICE EVALUATION (18ECI85)

SL
Parameter Split Details CO
NO
Organization
Internship Report Abstract and Conclusions
1 of chapters
20M 10M
10M

Presentation and Technical Conveying


Time
Communication content the
2 Management
Skills delivery Information
3M
10M 4M 3M

Answering the
Relevant and convincing answers
3 queries
10M
10M

TOTAL MARKS OBTAINED

Internship Co-ordinator & HOD


CONTENTS

1. COMPANY PROFILE………………………………………………………………………………….… 1
2. INTRODUCTION TO EMBEDDED SYSTEM
2.1 DEFINATION OF EMBEDDED SYSTEM ………...…………………..………………………………. 3

2.2 EMBEDDED SYSTEM HARDWARE ……………………………………………………………………. 3

2.3 EMBEDDED SYSTEM SOFTWARE …………………………………………………………………….. 3

2.4 TIME OPERATING SYSTEM……………………………………………………………………………….. 4

2.5 CHARACTERISTICS OF EMBEDDED SYSTE ….......................................................... 5

3. INTRODUCTION TO 8051 MICROCONTOLLER

3.1 8051-MICRONTROLLER ……………………………………………….……………………………...…… 6

3.2 FEATURES OF 8051 MICROCONTROLLER………………………………………………………….. 6

3.2 PIN CONFIGURATION OF 8051 MICROCONTROLLER ……………………..……………….... 7

3.4 STEPS TO CONFIGURE 8051-MICROCONTROLLER ………………………………………........ 8

4. TASK PERFORMANCE USING 8051 MICROCONTOLLER

4.1 LED BLINKING, INTERFACING PROGRAM ……………..……………………….………………... 9

4.2 LIQUID CRYSTEAL DISPLAY(LCD), INTERFACING PROGRAM ……………………….……. 10

4.3 SWITCH, INTERFACING PROGRAM……………………………………………………………...…. 12

4.4 DC MOTOR, INTERFACING PROGRAM……………………………………………….………….... 13

4.5 RELAY, INTERFACING PROGRAM …………………………………………………………….………. 14

4.6 BUZZER, INTERFACING PROGRAM …………………………………………………………………. 15

4.7 STEPPER MOTOR, INTERFACING PROGRAM …………………………………………………… 16

4.8 4x4 KEYPAD, INTERFACING PROGRAM …………………………………………….……………. 18

5.PROJECT OUTCOME (PASSWORD BASED DOOR LOOKING SYSTEM USING


MICROCONTROLLER)
5.1 INTRODUCTION………………………………………………………………………..……………………………… 23
5.2 HARDWARE COMPONENT REQUIRED…………………………………….……………………….. 24

5.3 MICROCONTROLLER…………………………………………………………………………………….…. 24

5.5 BLOCK DIAGRAM…………………………………………………………………………………………… 26

5.6 CIRCUIT DIAGRAM………………………………………………………………………………………… 27

5.7 PCB LAYOUT …………………………………………………………………………..……………………… 28

5.8 CODE…………………………………………………………………………………………………………….. 29

5.9 RESULT AND SIMULATION ……………………………………………….………………………...... 48

6. CONCLUSION ………………………………………………………………………………………………………….. 50

7. REFERENCE………………………………………………………….…………………………………………………… 51
EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

CHAPTER 1
COMPANY PROFILE

Karnataka German Technical Training Institute (KGTTI) is established by Karnataka


German Multi Skill Development Centre (KGMSDC) society. The primary mission of the
Training Centre is to conduct a broad based multidisciplinary vocational training in various
Industrial Technical Fields, directed towards the development of skills and trades and to
become a world class training centre that represents specialized trade training programs in
alignment with the industry requirements across the globe. Sister institutes are set up at
Bangalore, Kalburgi, Belgavi, Mangaluru, and Hubli.

All programs follow German vocational education and training standards that are demand
oriented and directly imply a close relationship with industry. To provide International
Standards and Hands-on training the centre is equipped with extensive state-of-art training
facilities which are incomparable.

With its world-class vocational training centres, KGTTI has set a benchmark in skill
development. The focus is to offer skill-specific training that will help students find excellent
job opportunities in the global workplace and encourage entrepreneurship among the youth.

KGMSDC society is recognized by Government of India and Government of Karnataka with


technical support of German International Services (GIZ-IS). KGMSDC is a registered society
formed under Society Registration Act 1960. The registered society has members from
Government of India and Government of Karnataka, complemented by local stakeholders and
representatives of industries, chambers and academia.

Department of ECE, GEC Ramanagara. 1


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

1.1 OBJECTIVES

The overall objective of KGTTI is to provide skill development, advanced technology hands-
on-training and to enhance employment opportunities. To achieve this objective, the DSATM
will mobilize its students/participants to undergo skill-development training to make them
industry ready/fit.

1.2 MISSION

KGTTI will generate high quality skilled manpower in close association with the industry,
will operating with operational flexibility and striving financial self-sustainability.

1.3 VISION

To develop KGTTI as world class training centres that offers specialized skills training
programs in alignment with the industry requirements in Karnataka and beyond.

1.4 AIMS

KGTTI is an organization providing technical skills training and consultancy services in


advanced technology areas to students, jobseekers, school dropouts, and unemployed youth
and industry personnel.

1.5 STRENGTHS

➢ Focus on technology-based services.


➢ Networking with expert organization of national and international repute.
➢ Handling of prestigious Job works for Aeronautical Development Agency.
➢ Dynamic work culture, professional staff, emphasis on result orientation and thrust on
client satisfaction.

1.6 KEY LEARNING AND SUCCESS

➢ Timely completion of jobs as per requirement of client.


➢ Ensuring customer satisfaction.
➢ Developed competence in developing competence-based training curriculum
developing system for its implementation.
➢ Adopted system of dynamic work culture & organization professionalism.

Department of ECE, GEC Ramanagara. 2


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

CHAPTER 2

INTRODUCTION TO EMBEDDED SYSTEM

2.1 DEFINATION OF AN EMBEDDED SYSTEM

An embedded system is one kind of a computer system mainly designed to perform several
tasks like to access, process, store and also control the data in various electronics-based
systems.

Embedded systems are a combination of hardware and software where software is usually
known as firmware that is embedded into the hardware.

2.2 EMBEDDED SESTEM HARDWARE

As with any electronic system, an embedded system requires a hardware platform on which it
performs the operation. Embedded system hardware is built with a microprocessor or
microcontroller. The embedded system hardware has elements like input output (I/O)
interfaces, user interface, memory and the display. Usually, an embedded system consists of:

➢ Power Supply
➢ Processor
➢ Memory
➢ Timers
➢ Serial communication ports

Department of ECE, GEC Ramanagara. 3


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

➢ System application specific circuits

2.3 EMBEDDED SYSTEM SOFTWARE

The embedded system software is written to perform a specific function. It is typically


written in a high-level format and then compiled down to provide code that can be lodged
within a non-volatile memory within the hardware. An embedded system software is
designed to keep in view of the three limits:

➢ Availability of system memory


➢ Availability of processor’s speed
➢ When the system runs continuously, there is a need to limit power dissipation for
events like stop, run and wake up.

2.4 REAL TIME OPERATING SYSTEM

A system is said to be real time, if it is essential to complete its work and deliver its service on
time. Real time operating system manages the application software and affords a mechanism
to let the processor run. The Real Time operating system is responsible for handling the
hardware resources of a computer and host applications which run on the computer.

Department of ECE, GEC Ramanagara. 4


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

2.5 CHARACTERISTICS OF AN EMBEDDED SYSTEMS

➢ Application-specific functionality – specialized for one or one class of applications.


➢ Deadline constrained operation – system may have to perform its function(s) within
specific time periods to achieve successful results.
➢ Resource challenged – systems typically are configured with a modest set of resources
to meet the performance objectives.
➢ Power efficient – many systems are battery-powered and must conserve power to
maximize the usable life of the system.
➢ Form factor – many systems are light weight and low volume to be used as components
in host systems.
➢ Manufacturable – usually small and inexpensive to manufacture based on the size and
low complexity of the hardware.

Department of ECE, GEC Ramanagara. 5


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

CHAPTER 3

INTRODUCTION TO 8051-MICROCONTROLLER

3.1 8051-MICRONTROLLER

8051 is one of the first and most popular microcontrollers also known as MCS-51. Intel
introduced it in the year 1981. Initially, it came out as an N-type metal-oxide-semiconductor
(NMOS) based microcontroller, but later versions were based on complementary metal-oxide-
semiconductor (CMOS) technology. These microcontrollers were named 80C51, where C in
the name tells that it is based on CMOS technology. It is an 8-bit microcontroller which means
the data bus is 8-bit. Therefore, it can process 8 bits at a time. It is used in a wide variety of
embedded systems like robotics, remote controls, the automotive industry, telecom
applications, power tools, etc.

3.2 FEATURES OF 8051 MICROCONTROLLER

➢ 4 KB on-chip ROM (Program memory).


➢ 128 bytes on-chip RAM (Data memory).
➢ The 8-bit data bus (bidirectional).
➢ 16-bit address bus (unidirectional).
➢ Two 16-bit timers.
➢ Instruction cycle of 1 microsecond with 12 MHz crystal.
➢ Four 8-bit input/output ports.
➢ 128 user-defined flags.
➢ Four register banks of 8 bit each.
➢ 16-byte bit-addressable RAM.
➢ The general-purpose registers are 32 each is 8-bit.
➢ 8051 has two external and three internal interrupts.
➢ 8051 microcontroller specifies some special function features like UARTs, ADC, Op-
amp, etc.
➢ It has a 16-bit program counter and data pointer

Department of ECE, GEC Ramanagara. 6


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

3.3 PIN CONFIGURATION OF 8051 MICROCONTROLLER

➢ Pins 1 to 8- These pins are known as PORT 1. This port doesn’t serve any other
functions. It is internally pulled up, bi-directional I/O port.
➢ Pins 9- It is a RESET pin. Which is used to Reset the microcontroller to its initial
values.
➢ Pins 10 to 17- These pins are known as PORT 3. This port serves some functions like
interrupt, timer input, control signals, serial communication signals RxD and TxD, etc.
➢ Pins 18 to 19- These pins are used for interfacing an external crystal to get the system
clock.
➢ Pin 20- This pin provides the power supply to the circuits.
➢ Pins 21 to 28- These pins are known as PORT 2. It serves as I\O port. Higher order
address bus signals are also multiplexed using this port.
➢ Pin 29- This pin PSEN pin which stands for External Program Store Enable. It is used
to read a signal from external program memory.
➢ Pin 30- This is EN pin which stands for External Access input. It is used to
enable/disable the external memory interfacing,
➢ Pin 31- This pin is ALE pin which stands for Adress Latch Enable. It is used to
demultiplexing the address data signal of port.
➢ Pins 32 to 39- These pins are known as PORT 0. It serves as I\O port, Lower order
address and data bus signals are multiplexed using this port.
➢ Pin 40- This pin is used to provide power supply to the circuits.

Department of ECE, GEC Ramanagara. 7


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

3.4 STEP TO CONFIGURE 8051-MICROCONTROLLER

1.Select a Microcontroller: - Choose a microcontroller that suits your project requirements.

2.Setup Development Environment: - Install the necessary software tools, like an Integrated
Development Environment (IDE), compiler and programmer software.

3.Connect hardware: - Connect the microcontroller to your development board, ensuring


proper power supply and connections.

4.Write Code: - Develop your program using the programming language supported by the
microcontroller. Write code to initialize peripherals, handle inputs/outputs and implement the
desired functionality.

5.Compile code: - Use the compiler to translate your code into machine readable instruction
for the microcontroller.

6.Load Code onto Microcontroller: - Use a programmer tool to transfer the microcontroller’s
memory.

7.Debugging: - Test and debug your code to identify and fix any errors or issues.

8.Configure Peripherals: - Set up and configure any peripherals, such as sensor, actuators or
communication modules, as needed for your projects.

9.Testing: - Conduct thorough testing to ensure your microcontroller operates as intended in


different scenario.

10.Documentation: - Document your code, connections and configurations for future


reference or collaboration.

Department of ECE, GEC Ramanagara. 8


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

CHAPTER 4

TASK PERFORMANCE USING 8051 MICROCONTOLLER

4.1 LED BLINKING

A light-emitting diode (LED) is a two-lead semiconductor light source device used for
indicating the output status by making it ON or OFF.

An LED is nothing but a p–n junction diode, which emits light when provided with power
supply. When voltage is applied to the leads of an LED, it forces the electrons to recombine
with electron holes within the device, emitting energy in the form of photons. This effect of
emitting energy in form of photons is called electroluminescence.

The colour of the light is determined by the energy band gap of the semiconductor
corresponding to the energy of the photon.

INTERFACING LED PROGRAM TO 8051 MICROCONTROLLER

#include<reg51.h>
void delay ()
{
TMOD=0X01;
TH0=0XDB;
TL0=0XFF;
TR0=1;
while (TF0==0)
TF0=0;
}
void main ()
{
while (1)
{

Department of ECE, GEC Ramanagara. 9


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

P1=0xAA;
delay ();
P1=0x55;
delay ();
P2=0xFF;
delay ();
P2=0x00;
delay ();
}
}
4.2 LIQUID CRYSTEL DISPLAY (LCD)

LCDs (Liquid Crystal Displays) are used for displaying status or parameters in embedded
systems. LCD 16x2 is 16 pin device which has 8 data pins (D0-D7) and 3 control pins (RS,
RW, EN). The remaining 5 pins are for supply and backlight for the LCD.

The control pins help us configure the LCD in command mode or data mode. They also help
configure read mode or write mode and also when to read or write.

LCD 16x2 can be used in 4-bit mode or 8-bit mode depending on the requirement of the
application. In order to use it we need to send certain commands to the LCD in command mode
and once the LCD is configured according to our need, we can send the required data in data
mode.

Since we are using LCD in 4-bit mode, we require only 4 Data pins.
LCD Data pins D4-D7 are connected to respective pins.
LCD control pins RS, RW and EN are connected to their respective pins.
INTERFACING LCD PROGRAM TO 8051 MICROCONTROLLER
#include<reg51.h>
#define display P2
sbit rs=P3^7;
sbit rw=P3^6;
sbit en=P3^5;

Department of ECE, GEC Ramanagara. 10


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

void delay()
{
int i,j;
for(i=0;i<100;i++)
for(j=0;j<100;j++);
}
void lcdcmd(unsigned char cmd)
{
display=cmd;
rw=0;
rs=0;
delay();
en=1;
delay();
en=0;
delay();
}
void lcddat(unsigned char dat)
{
display=dat;
rw=0;
rs=1;
delay();
en=1;
delay();
en=0;
delay();
}
void lcdstr(char*str)
{
while(*str!='\0')
{
lcddat(*str);
str++;
}
}
void main()
{
while(1)

Department of ECE, GEC Ramanagara. 11


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

{
lcdcmd(0x38);
lcdcmd(0x01);
lcdcmd(0x0e);
lcdcmd(0x80);
lcdstr("RAMALINGEGOWDA");
lcdcmd(0xc0);
lcdstr("SUGUNAGOWDA");
}
}

4.3 SWITCH
The switch is a basic input device, use to control the operation of any output device using the
microcontroller or control unit.

INTERFACING SWICH PROGRAM 8051 MICROCONTROLLER


#include<lpc213x.h>
void main()
{
int i , j ;
for(i=0;i<200;i++)
for(j=0;j<200;j++);
}
Int main()
{
IODIR0=1<<20;
while(1)
{
IOSET0=1<<20;
delay();
IOCLR0=1<<20;
delay();
}
}

Department of ECE, GEC Ramanagara. 12


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

4.4 DC MOTOR
The term ‘DC motor’ is used to refer to any rotary electrical machine that converts direct
current electrical energy into mechanical energy. DC motors can vary in size and power from
small motors in toys and appliances to large mechanisms that power vehicles, pull elevators
and hoists, and drive steel rolling mills. But how do DC motors work?

DC motors include two key components: a stator and an armature. The stator is the stationary
part of a motor, while the armature rotates. In a DC motor, the stator provides a rotating
magnetic field that drives the armature to rotate.

A simple DC motor uses a stationary set of magnets in the stator, and a coil of wire with a
current running through it to generate an electromagnetic field aligned with the centre of the
coil. One or more windings of insulated wire are wrapped around the core of the motor to
concentrate the magnetic field.

The windings of insulated wire are connected to a commutator (a rotary electrical switch), that
applies an electrical current to the windings. The commutator allows each armature coil to be
energised in turn, creating a steady rotating force (known as torque).

When the coils are turned on and off in sequence, a rotating magnetic field is created that
interacts with the differing fields of the stationary magnets in the stator to create torque, which
causes it to rotate. These key operating principles of DC motors allow them to convert the
electrical energy from direct current into mechanical energy through the rotating movement,
which can then be used for the propulsion of object.

INTERFACING DC MOTOR PROGRAM TO 8051 MICROCONTROLLER


#include<reg51.h>
sbit sw1=P2^7;
sbit sw2=P2^6;
sbit In1=P1^7;

Department of ECE, GEC Ramanagara. 13


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

sbit In2=P1^6;
void main()
{
sw1=sw2=1;
In1=In2=0;
while(1)
{
if(sw1==1&sw2==0)
{
In1=1;
In2=0;
}
else if(sw1==0&sw2==1)
{
In1=0;
In2=1;
}
else
{
In1=0;
In2=0;
}
}
}
4.5 RELAY

A relay is an electrically operated switch. It consists of a set of input terminals for a single or
multiple control signals, and a set of operating contact terminals. The switch may have any
number of contacts in multiple contact forms, such as make contacts, break contacts, or
combinations thereof. It works on electromagnetic induction and has operating voltage of +5V.

Department of ECE, GEC Ramanagara. 14


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

INTERFACINR RELAY PROGRAM TO 8051 MICROCONTROLLER


#include<213x.h>
void delay()
{
Int i, j;
for(i=0; i<200;i++)
for(j=0; j<200;j++);
}
void main()
{
IODIR=1<<20;
while(1)
{
IOSET=1<<20;
delay();
IOCLR=1<<20;
delay();
}
}

4.6 BUZZER

A buzzer or beeper is an audio signalling device, which may be mechanical, electromechanical


or piezoelectric. Typical uses of buzzers and beepers include alarm devices, timers, train and
confirmation of user input such as a mouse click or keystroke.

Department of ECE, GEC Ramanagara. 15


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

INTERFACING BUZZER PROGROM TO 8051 MICROCONTROLLER

#include<213x.h>
void delay()
{
Int i, j;
for(i=0; i<200;i++)
for(j=0; j<200;j++);
}
void main()
{
IODIR=1<<20;
while(1)
{
IOSET=1<<20;
delay();
IOCLR=1<<20;
delay();
}
}

4.7 STEPPER MOTOR

A stepper motor, also known as step motor or stepping motor is an electrical motor that rotates
in a series of small angular steps, instead of continuously. Stepper motors are a type of digital
actuators. Stepper motors are an electromagnetic actuator; it converts electromagnetic energy
into mechanical energy to perform mechanical work.

Department of ECE, GEC Ramanagara. 16


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

A stepper motor is a brushless DC electric motor that divides a full rotation into a number of
equal steps. The motor's position can be commanded to move and hold at one of these steps
without any position sensor for feedback (an open-loop controller), as long as the motor is
correctly sized to the application in respect to torque and speed.

Switched reluctance motors are very large stepping motors with a reduced pole count, and
generally are closed-loop commutated.

INTERFACING STEPPER MOTOR TO 8051 MICROCONTROLLER


#include<reg51.h>
void delay()
{
int i,j;
for(i=0;i<100;i++)
for(j=0;j<100;j++);
}
void main()
{
while(1)
{
P1=0x33;
delay();
P1=0x66;
delay();
P1=0xcc;
delay();
P1=0x99;
delay();
}
}

Department of ECE, GEC Ramanagara. 17


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

4.8 4x4 KEYPAD


The 4 x 4 matrix keypad usually is used as input in a project. It has 16 keys in total, which
means the same input values. The 4 x 4 Matrix Keypad Module is a non-encoded matrix keypad
consisting of 16 keys in parallel. The keys of each row and column are connected through the
pins outside – pin R1-R4 as label beside control the rows, when L1-L4, the columns.

A 4×4 matrix keypad consisting of microswitch buttons. The module has four holes 3mm (M3)
holes for mounting. The pin designations on each PCB are shown on each PCB. Four pins are
thus used as an ‘x’ coordinate and the other 4 as a ‘y’ coordinate.

INTERFACING 4x4 KEYPAD PROGRAM TO 8051 MICROCONTROLLER

#include<reg51.h>
#define display P1
sbit RS=P3^1;
sbit E=P3^2;
sbit r1=P2^0;
sbit r2=P2^1;
sbit r3=P2^2;
sbit r4=P2^3;
sbit c1=P2^7;
sbit c2=P2^6;
sbit c3=P2^5;
void delay()
{
int i,j;

Department of ECE, GEC Ramanagara. 18


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

for(i=0;i<100;i++)
for(j=0;j<100;j++);
}
void lcd_cmd(unsigned char cmd)
{
display=cmd;
RS=0;
delay();
E=1;
delay();
E=0;
delay();
}
void lcd_dat(unsigned char dat)
{
display=dat;
RS=1;
delay();
E=1;
delay();
E=0;
delay();
}
void main()
{
P1=0x00;
lcd_cmd(0x38);
lcd_cmd(0x01);
lcd_cmd(0x0e);

Department of ECE, GEC Ramanagara. 19


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

lcd_cmd(0x80);
while(1)
{
r1=0;
if(c1==0)
{
lcd_dat('1');
delay();
}
if(c2==0)
{
lcd_dat('2');
delay();
}
if(c3==0)
{
lcd_dat('3');
delay();
}
r1=1;r2=0;
if(c1==0)
{
lcd_dat('4');
delay();
}
if(c2==0)
{
lcd_dat('5');
delay();

Department of ECE, GEC Ramanagara. 20


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

}
if(c3==0)
{
lcd_dat('6');
delay();
}
r2=1;r3=0;
if(c1==0)
{
lcd_dat('7');
delay();
}
if(c2==0)
{
lcd_dat('8');
delay();
}
if(c3==0)
{
lcd_dat('9');
delay();
}
r3=1;r4=0;
if(c1==0)
{
lcd_dat('*');
delay();
}
if(c2==0)

Department of ECE, GEC Ramanagara. 21


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

{
lcd_dat('0');
delay();
}
if(c3==0)
{
lcd_dat('#');
delay();
}
r4=1;
}
}

Department of ECE, GEC Ramanagara. 22


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

CHAPTER 5
PROJECT OUTCOME
PASSWORD BASED DOOR LOCKING SYSTEM USING
MICROCONTROLLER

ABSTRACT

The purpose of this project is to provide security at (house, ATM, office etc.) in this system the
user will have to register a unique password. The information will be stored in data base.
Whenever the right password will be received, the controller will accordingly give instruction
to dc motor. Dc motor will perform the action on door unlocking. We want to utilize the
electronic technology to build an integrated and fully customized home security system at a
reasonable cost.

5.1 INTRODUCTION

Many time we forgot to carry the key of our home. Or sometimes we come out of our home
and door latch closes by mistake. In this case it is really difficult to get inside the house. This
project is designed to solve this purpose. Main concept behind this project is of a door-latch
opening using a password entered through keypad. As well as turning on the Buzzer when
password is entered wrong. Today people are facing more problems about security in all over
world, nowadays security is the most essential issue everywhere in the world so security of
everything gains higher and higher importance in recent years. The main component in the
circuit is 8051-Microcontroller. Here, 4*4 keypad is used to enter the password. The entered
password is compared with the predefined password. If it is correct password, the system opens
the door by rotating door motor and displays the status of door on LCD. If the password is
wrong then door remains closed and displays password is wrong on LCD. It can be used at
organizations to ensure authorized access to highly secured places. With a slight modification
by replacing the motor driver with a relay driver, this circuit can be used to control the
switching of loads through code. This circuit can be also modified by using EEPROM chip
interfaced to the microcontroller and store the entered password in the chip. Such an
automatic lock system consists of electronic control assembly which controls the output load
through a password. This output load can be a motor or a lamp or any other
mechanical/electrical load.

Department of ECE, GEC Ramanagara. 23


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

5.2 HARDWARE COMPONENT REQUIRD

➢ 8051 Microcontroller
➢ LCD display

➢ Buzzer

➢ 4x4 Keypad

➢ Motor Driver IC(L293D)

5.3.1 MICROCONTROLLER
This is the CPU (central processing unit) of our project. We are going to usea Microcontroller
of 8051 family. The various functions of microcontroller are like:

• Reading the digital input from Keypad.


• Sending this data to LCD so that the person operating this project should read the
password.
• Sensing the password using keypad and to check whether it is a correct password or a
wrong password and rotate the stepper motor if the password entered is a correct
password.

5.3.2 LCD DISPLAY

We are going to use 16x2 alphanumeric Liquid Crystal Display (LCD) which means it can
display Alphabets along with numbers on 2 lines each are containing 16 characters.

5.3.3 BUZZER

We are going to use a buzzer to indicate the wrong password to open the door.

Department of ECE, GEC Ramanagara. 24


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

5.3.4 4x4 KEYPAD

input User will enter the password using the keypad. In our project we are using 4*4 matrix
to providethe inputs.

5.3.5 MOTOR DRIVER:

The Actuator's are those devices which actually gives the movement or to do a task like motor's.
In the real world there are various types of motors available which works on different voltages.
So, we need motor driver for running them through the controller. To get interface between
motor and Microcontroller. We use L293D motor driver IC in our circuit.

5.3.6 SOFTWARE REQUIRD


1.Kiel compiler
2.Proteus
3.Flash Magic

5.4 METHODOLOGY

Electronic Code Lock System Circuit Design: Password Based Door Locking System design
uses five major components – a Microcontroller, an L293D Motor Driver, a DC motor, a 4×4
matrix keypad and anLCD. Here AT89C52 Microcontroller is used and it is an 8-bit controller.
This controller requires a supply voltage of +5V DC. In order to provide regulated 5V DC
voltage to the controller we need to use 7805 power supply circuit. We can use 9V DC battery
or 12V, 1A adaptor as a power source.

Reset Circuit Design: The reset pin of the microcontroller is kept active till the power supply
is inthe specified range and a minimum oscillation level is maintained. In other words to ensure
the supply voltage does not falls below the threshold level of 1.2V and the reset pulse width is

Department of ECE, GEC Ramanagara. 25


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

greater than 100ms (recommended for 89C51), we select the values of resistor and capacitor
such that RC >=100ms. Here we select a 10K resistor and a 10uF electrolyte capacitor.

Oscillator Circuit Design: A crystal oscillator is used to provide external clock signal to the
microcontroller. To ensure smooth operation, we connect two ceramic capacitors ranges from
20pF to 40pF. This crystal oscillator is connected between pin 18 and 19 of the
microcontroller.

Compilation of Microcontroller Code: Once the circuit is designed and drawn on a piece of
paper, the next step is to write and compile the code. Here we select the Kiel µVision
software to write the program in C language. Prior to writing the code, general steps needs to
be followed like creating a new project and selecting the target device or the required
microcontroller. Once the code is written, we saved it with .c extension and then added it to the
source file group under the target folder. The code is then compiled by pressing F7 key. Once
the code is compiled, a hex file is created. In the next step, we use Proteus software to draw the
circuit. The code is dumped into the microcontroller by right clicking on the IC and then adding
the hex file

5.5 BLOCK DIAGRAM

The Microcontroller based door locker is an access control system that allows only authorized
person to access a restricted area. The system is fully controlled by the 8-bit microcontroller
8051 which has a 2Kbytes of ROM for the program memory. The password is stored in the
EPROM so that we can change it at any time. The system has a keypad by which the password
can be entered through it. When the entered password equals with the password stored in the
memory then the relay gets on and so that the door is opened. If we entered a wrong password

Department of ECE, GEC Ramanagara. 26


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

then the alarm is switched on. An easy way to comply with the conference paper formatting
requirements is to use this document as a template and simply type your text into it.

5.6 CIRCUIT DIAGRAM

Principle Behind the Circuit: The main component in the circuit is 8051 microcontroller.
Here, 4×3 keypad is used to enter the password. The entered password is compared with the
predefined password. If it is correct password, the system opens the door by rotating door motor
and displays the status of door on LCD.
If the password is wrong then door remains closed and displays ―pwd is wrong‖ on LCD Its
design and working are very interesting and easy to implement. If you are interested to get
detailed information about its design, working and applications, read the post Electronic Code
Lock System using 8051 Microcontroller. Traditional lock systems using mechanical lock and
key mechanism are being replaced by new advanced techniques of locking system. These
techniques are an integration of mechanical and electronic devices and highly intelligent. One
of the prominent features of these innovative lock systems is their simplicity and high
efficiency.

Circuit Description: The total functioning of the―CODE LOCK SYSTEM is based on the
software program which is burn inside the microcontroller IC 8051.The at89c51 IC is heart of
the given circuitry because this IC is programmable 40pin dip IC in which we burn the program
in rom. This IC has a 32 input lines through which we take the output pin no 9 is used for reset

Department of ECE, GEC Ramanagara. 27


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

the microcontroller and make it in a initial condition pin no 31 is enable pin, it required low
pulse for activating the microcontroller depends on the crystal connected to the xtal1 & xtal2.
pin no 18 & 19 is used for providing the VCC of +5v pin 20 is grounded.

The operating frequency of the controller is set by the external oscillator of crystal oscillator
of crystal having frequency of 12MHZ. Capacitor having 33pF in parallel connection with
ground is for the proper undammed frequency. Reset for the controller is normally ground and
10uf 10v electrolytic capacitor is also connected on reset for the slowly on and off to the
controller during the supply is turning on and off. The keypad used to give input signal is been
interfaced with microcontroller are port0 (p0.1- p0.7). The controller fetches the hex code
according to the instruction. The LCD is used for display device it is a 16 slots device usually
used to show output status from the microcontroller. The output signal which be fetched by
relay status followed by on/off status of electronic lock.

5.7 PCB LAYOUT

Department of ECE, GEC Ramanagara. 28


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

5.8 CODE

#include "uart.h"
#include "timer0.h"
void GSM_init(void)
{
serial_print("ATE0");
serial_tx(0x0D);//carriage return
delay_max_t0m1(14);
serial_print("AT+IPR=9600");
serial_tx(0x0D);
delay_max_t0m1(14);
serial_print("AT");
Serial_tx(0x0D);
delay_max_t0m1(14);
}
void sendSMS(unsigned int otp)
{
serial_print("AT+CMGF=1");
serial_tx(0x0D);
delay_max_t0m1(14*2);
serial_print("AT+CMGS=\"+918749069465\"");
serial_tx(0x0D);
delay_max_t0m1(1);
serial_print("New Password for Door Lock is :");
serial_print_int(otp);
serial_tx(0x1A);// End of file or ctrl + Z
delay_max_t0m1(14*2);
}
#ifndef GSM
#define GSM
void GSM_init(void);

Department of ECE, GEC Ramanagara. 29


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

void sendSMS(unsigned int);


#endif
unsigned int GetKeypadValue(void)
{
unsigned char data1;
P1=0x0f;
while(1)
{
P1=0x7f; //1
data1 = P1&0x0f;
if(data1==0x0e)
{
return 1;
while((data1==0x0e));
}
else if(data1==0x0d)
{
return 4;
while(data1==0x0d);
}
else if(data1==0x0b)
{
return 7;
while(data1==0x0b);
}
else if(data1==0x07)
{
return 42;
while(data1==0x07);
}
P1=0xbf; //2

Department of ECE, GEC Ramanagara. 30


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

data1 = P1&0x0f;
if(data1==0x0e)
{
return 2;
while((data1==0x0e));
}
else if(data1==0x0d)
{
return 5;
while(data1==0x0d);
}
else if(data1==0x0b)
{
return 8;
while(data1==0x0b);
}
else if(data1==0x07)
{
return 0;
while(data1==0x07);
}

P1=0xdf; //3
data1 = P1&0x0f;
if(data1==0x0e)
{
return 3;
while((data1==0x0e));
}
else if(data1==0x0d)

Department of ECE, GEC Ramanagara. 31


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

{
return 6;
while(data1==0x0d);
}
else if(data1==0x0b)
{
return 9;
while(data1==0x0b);
}
else if(data1==0x07)
{
return 35;
while(data1==0x07);
}
}
}
#ifndef keypad
#define keypad
unsigned int GetKeypadValue(void);
#endif
#define lcd P2
#include "lcd_2x16.h"
//#include<string.h>
sbit rs = P3^7;
sbit en = P3^5;
sbit rw=P3^6;
void lcd_cmd(unsigned char cmd)
{
lcd = cmd;
rw=0;

Department of ECE, GEC Ramanagara. 32


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

rs =0;
en =1;
lcd_delay(1);
en=0;
}
void lcd_begin(void)
{
lcd_cmd(0x38); //setting as 8 bit 2 line
lcd_cmd(0x0c); //display on cursor
lcd_cmd(0x01); //clear
lcd_cmd(0x06); //aut increment
}
void lcd_cursor(unsigned char r,unsigned char pos) //pos starts from 0
{
unsigned char set;
rw=0;
if(r==0)
{
set=0x80+pos;
lcd_cmd(set);
}
else if(r==1)
{
set=0xc0+pos;
lcd_cmd(set);
}
}
void lcd_print(unsigned char *data1)
{
while(*data1!='\0')

Department of ECE, GEC Ramanagara. 33


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

{
lcd =*data1;
rw=0;
rs =1;
en =1;
lcd_delay(10);
en=0;
data1++;
}
}
void lcd_clear()
{
lcd_cmd(0x01); //display on cursor
}
void lcd_data(unsigned char data1)
{
lcd =data1;
rw=0;
rs =1;
en =1;
lcd_delay(10);
en=0;
}
void lcd_print_int_3d(unsigned int i)
{
lcd_data((i/100)%10+0x30);
lcd_data((i/10)%10+0x30);
lcd_data((i/1)%10+0x30);
}
void lcd_delay(int d)

Department of ECE, GEC Ramanagara. 34


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

{
unsigned i,j;
for(i=0;i<d;i++)
{
for(j=0;j<10;j++);
}
}

#ifndef LCD_2X16
#define LCD_2X16
void lcd_begin(void);
void lcd_cmd(unsigned char cmd);
void lcd_print(unsigned char *data1);
void lcd_cursor(unsigned char r,unsigned char pos);
void lcd_clear();
void lcd_data(unsigned char data1);
void lcd_print_int_3d(unsigned int i);
void lcd_delay(int d);
#endif
#include "lcd_2x16.h"
#include "keypad.h"
#include "main.h"
#include "lcd_2x16.h"
#include "timer0.h"
#include "motor.h"
#include "uart.h"
#include "gsm.h"
unsigned int passrd=940,c=1;
unsigned char Value;
sbit intr=P2^1;

Department of ECE, GEC Ramanagara. 35


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

void msg(char msg1[],char msg2[])


{
lcd_clear(); //LCD Clear
lcd_cursor(0,1); //cursor to 1st line
lcd_print(msg1); //msg on 1st line
lcd_cursor(1,0); //cursor to 2nd line
lcd_print(msg2); //msg on 2nd line
}
void OneMsg(unsigned char msg[])
{
lcd_clear(); //LCD Clear
lcd_cursor(0,1); //cursor on 1st line
lcd_print(msg); //MSG
}
unsigned int GetValue()
{
static unsigned char msg1[17]=" Enter Password"; //Variable Declarationunsigned
int d1=-1,d2=-1,d3=-1,FinalValue;
//for(i=0;i<3;i++)
{
OneMsg(msg1); //MSG=" Enter Password";
lcd_cursor(1,1); //cursor on 2nd ROW for printing password enter
while(d1 == -1)
{
d1=GetKeypadValue(); //Password 1st Digit value
}
lcd_data('*'); //Printing 1st value
delay_max_t0m1(7); //0.5sec delay
while(d2 == -1)
{
d2=GetKeypadValue(); //Password 2nd Digit value

Department of ECE, GEC Ramanagara. 36


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

}
lcd_data('*'); //Printing 2nd value
delay_max_t0m1(7); //1sec delay
{
d3=GetKeypadValue(); //Password 3rd Digit value
}
lcd_data('*');
//Printing 3rd value
delay_max_t0m1(7); //1sec delay
FinalValue=d1*100+d2*10+d3;
//Combined Final value
lcd_cursor(1,1);
//Cursor to 2nd line to print value
lcd_print_int_3d(FinalValue); //Printing Final value
delay_max_t0m1(14); //1sec delay
} //d1=-1;d2-1;d3=-1;
return FinalValue;
}
unsigned int checking(void)
{
static unsigned int FinalValue;
FinalValue=GetValue();
//Getting Number entered
if(FinalValue == passrd)
//Comparing Password entered
{
OneMsg(" Correct Password"); //Msg="Correct Password";
delay_max_t0m1(14); //1sec delay
return 0;
}
else
{

Department of ECE, GEC Ramanagara. 37


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

msg(" Password entered"," is WRONG "); //Msg="Wrong Message";


delay_max_t0m1(14*3);
//0.5sec delay
return 1;
}
}
void srand(void)
{
unsigned char a1,a2,a3;

// done:
while(c)
{
for(a1=9;a1>=0;a1--) //Number generation
{
for(a2=9;a2>=0;a2--)
{
for(a3=9;a3>=0;a3--)
{
//Value=(a1|a2|a3);
Value = (a1 * 100) + (a2 * 10) + a3;
if(intr==0)
{
GSM_init();
sendSMS(Value);
intr=1;
c=0;
//goto done;
return;
}
}

Department of ECE, GEC Ramanagara. 38


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

}
}
}
}
int otpgen(void)
{
unsigned char Val;
msg(" OTP will be send","to your Phn No.");
delay_max_t0m1(14*3);
//1sec delay//---------------------------------//---------------------------------
new:
msg(" Press Switch 3 ","for sending OTP.");
delay_max_t0m1(14);
srand();
c=1;
msg(" Enter the OTP "," after Recieving ");
delay_max_t0m1(14*5);
Val=GetValue();
if(Val == Value)
{
msg(" Entered OTP is "," Correct. ");
delay_max_t0m1(14*3);
msg(" Entered the New "," Password. ");
delay_max_t0m1(14*5);
passrd=GetValue();
msg(" New Password is"," is Set ");
delay_max_t0m1(14*5);
//1sec delay
return 0;
}
else

Department of ECE, GEC Ramanagara. 39


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

{
return 1;
}
}
void OTP(void)
{
//int z;
while(otpgen())
{
{
/*lcd_clear();
lcd_cursor(0,2);
//Cursor to 2nd line to print value
lcd_print_int_3d(Value);
delay_max_t0m1(14*3);*/
msg(" Entered OTP is "," InCorrect. ");
delay_max_t0m1(14*3);
}
}
}
void true(void)
{
msg(" Please Enter"," The House ");
//Printing Welcome Message
delay_max_t0m1(14*3);
//5sec delay
DoorMotor();
//Open Door If Password is correct
msg(" The Door is "," Closed NOW ");
//Printing Welcome Message
delay_max_t0m1(14*30);
//5sec delay

Department of ECE, GEC Ramanagara. 40


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

}
void main()
{
static unsigned char start1[17]=" Wellcome to",start2[17]=" Smart Home";

//Variable Declaration
unsigned char check=1,i=0;
intr=1;
while(1)
{
lcd_begin();
//LCD start
msg(start1,start2);
//Printing Welcome Message
delay_max_t0m1(14*5);
//5sec delay
//while(1)
{
if(check=checking())
{
if(check=checking())
{
if(check=checking())
{
OTP();
//Sending OTP to Mobile
msg(" Password Change "," is Successful. ");
//Printing Welcome Message
delay_max_t0m1(14*5);
//5sec delay
}
else
{

Department of ECE, GEC Ramanagara. 41


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

true(); // If password is true


}
}
else
{
true(); // If password is true
}
}
else
{
true(); // If password is true
}
}
}
}
#ifndef MAIN
#define MAIN
#endif
#include "timer0.h"
#include "lcd_2x16.h"
sbit I1=P0^0;
sbit I2=P0^1;
sbit E1=P0^2;
void DoorMotor(void)
{
E1=1;
//1st Direction
I1=1;
I2=0;
delay_max_t0m1(14*5); //5sec delay

Department of ECE, GEC Ramanagara. 42


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

I1=0;
delay_max_t0m1(14*5); //3sec delay
I1=0;
I2=1;
delay_max_t0m1(14*5); //5sec delay
I2=0;
delay_max_t0m1(14*5); //3sec delay
}/*
main()
{
lcd_begin();
lcd_cursor(0,1);
lcd_print(" Motor Starting");
delay_max_t0m1(14*2);
DoorMotor();
lcd_clear();
lcd_cursor(0,1);
lcd_print(" Motor stopped");
delay_max_t0m1(14*2);
}*/
#ifndef motor
#define motor
void DoorMotor(void);
#endif
#include "timer0.h"
#include "lcd_2x16.h"
sbit I1=P0^0;
sbit I2=P0^1;
sbit E1=P0^2;
void DoorMotor(void)

Department of ECE, GEC Ramanagara. 43


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

{
E1=1; //1st Direction
I1=1;
I2=0;
delay_max_t0m1(14*5); //5sec delay
I1=0;
delay_max_t0m1(14*5); //3sec delay
I1=0;
I2=1;
delay_max_t0m1(14*5); //5sec delay
I2=0;
delay_max_t0m1(14*5); //3sec delay
}/*
main()
{
lcd_begin();
lcd_cursor(0,1);
lcd_print(" Motor Starting");
delay_max_t0m1(14*2);
DoorMotor();
lcd_clear();
lcd_cursor(0,1);
lcd_print(" Motor stopped");
delay_max_t0m1(14*2);
}*/
#include "timer0.h"
void delay_max_t0m1(unsigned int d)
{
unsigned int j; //one time run gives 71.17msec
TMOD =0x01;

Department of ECE, GEC Ramanagara. 44


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

for(j=0; j<d ; j++)


{
TH0 = 0x4c;
TL0 = 0x00;
TR0 = 1;
while(TF0==0);
TF0=0;
TR0=0;
} //make sure that you stop the timer else in nextime ican give wrong info think about it
}
#ifndef TIMER
#define TIMER
///////////////////////////Timer 0 Mode 0/////////////////////////////
///////////////////////////Timer 0 Mode 1/////////////////////////////
void delay_max_t0m1(unsigned int d);
#endif
#include "timer0.h"
void delay_max_t0m1(unsigned int d)
{
unsigned int j; //one time run gives 71.17msec
TMOD =0x01;
for(j=0; j<d ; j++)
{
TH0 = 0x4c;
TL0 = 0x00;
TR0 = 1;
while(TF0==0);
TF0=0;
TR0=0;
} //make sure that you stop the timer else in nextime ican give wrong info think about it

Department of ECE, GEC Ramanagara. 45


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

}
#include "uart.h"
char serialBuff[10];
void serial_begin_9600(void)
{
TMOD = TMOD | 0x20;
SCON = 0x50;
TL1 = -3;
TH1 = -3;
TR1 = 1;
}
void serial_print(unsigned char *p)
{
serial_begin_9600();
while( (*p)!='\0' )
{
SBUF = *p;
TR1 = 1;
while(TI == 0);
TI = 0;
p++;
}
}
void serial_tx(unsigned char p)
{
serial_begin_9600();
SBUF = p;
while(TI == 0);
TI=0;
}

Department of ECE, GEC Ramanagara. 46


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

void serial_print_int(unsigned int i)


{
serial_begin_9600();
serial_tx( ((i/100)%10 +0x30) );
serial_tx( ((i/10)%10 +0x30) );
serial_tx( ((i/1)%10 +0x30) );
}
#ifndef UART
#define UART
void serial_begin_9600(void);
void serial_print(unsigned char *p);
void serial_tx(unsigned char p);
void serial_print_int(unsigned int i);
#endif

Department of ECE, GEC Ramanagara. 47


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

5.7 RESULT AND SIMULATION


➢ When it is entered a 4-digit password by the user it will display on LCD as ****.
Therefore, anyone else can’t see what the user enters.
➢ If it is the correct password, LCD displaying a message ―Well come and the door will
beopened. after 1minute time door is locked automatically.
➢ If he is entered password incorrectly LCD displaying ―password error.
➢ After opening the door if user wants to change his password, after pressing ―0 key
and giving user id user can change his password.
➢ If user wants to add more people to the system after opening the door pressing ―# key,
user can add more users. System will give user id to each password.

Simulation of project is performed on PROTEUS and the code was written Kiel software. Code
for the microcontroller to run DC motors IC (L293D) is written. In the simulation the relevant
data to the Microcontroller is send through keypad. The Microcontroller processed the data
and sent the information to the Actuator IC (L293D). The Actuator IC upon receiving
information showed response by driving the DC motors.

Here we are discussing the result in different cases as once when wrong password is entered
the LCD displays “wrong password” entered and when correct password is entered the LCD
shows the “access granted” and the motor rotates to open the door.

Case 1: when wrong password is entered the doordoesn’t open.

Department of ECE, GEC Ramanagara. 48


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

Case 2: When correct password is entered the door get open.

Department of ECE, GEC Ramanagara. 49


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

CHAPTER 6

CONCLUSION

The work was done successfully. It is evidence that the use of keypad with the right circuitry
can be used to operate a security system. These systems have the ability to accesses a secure
place (house, ATM, industries, office etc). A password-based recognition system can easily
perform variation. In variation the system compares an input password to the enrolled password
of a specific user to determine, if they are forming the same password. Now the security of
our home,office etc.

FUTURE SCOPE

❖ We can send this data to a remote location using mobile or internet.


❖ We can add fingerprint sensor so entry will be allowed for the authorized person using
their fingerprints.
❖ We can add fire, wind and LPG sensors so that, the doors will automatically open.

Department of ECE, GEC Ramanagara. 50


EMBEDDED PROGRAMMING & INTERFACE OF 8/16/32 BIT MICROCONTROLLER 1GG20EC039

CHAPTER 7

REFERENCE

1. Technology Intelligent Home: SMS Based Home Security System with Immediate
Feedback International Journal of Advance Research In Science And Engineering
http://www.ijarse.com IJARSE, Vol. No.2, Issue No.5, May, 2013 ISSN-2319-
8354(E).
2. Liu, T., Guo, H., and Wang, Y., A new approach for colour-based object recognition
aqwith fusion of colour models‖, Congress on Image and Signal Processing Conference,
Sanya-China, vol. 3, pp. 456-460, May 2008.
3. Wang, B., and Yuan, T., Traffic Police Gesture Recognition using Accelerometer‖,
IEEE SENSORS Conference, Lecce-Italy, pp. 1080-1083, Oct. 2008.
4. Lalanne, Colour recognition with a camera: a supervised algorithm for classification‖,
IEEE Southwest Symposium on Image Analysis and Interpretation, Tucson-Arizona,
pp. 198-204, April 1998.
5. Signals, Systems and Computers, 2004 Conference Record of the Thirty-Eighth
Asilomar Conference on Publication 7-Nov-2004 Volume: 1, on page(s): 577-581
Vol.1.
6. International Journal of Advanced Research in Computer Science and Software
Engineering, Volume 2, Issue 10, October 2012.
7. International Journals of Biometric and Bioinformatics, Volume (3): Issue (1).
8. Mukesh Kumar Thakur, Ravi Shankar Kumar, Mohit Kumar, Raju Kumar Wireless
Fingerprint Based Security System using Zigbee‖ , International Journal of Inventive
Engineering and Sciences (IJIES) ISSN: 2319–9598, Volume-1, Issue-5, April 2013.
9. Mary Lourde R and Dushyant Khosla, Fingerprint Identification in Biometric
Security Systems‖, International Journal of Computer and Electrical Engineering, Vol.
2, No. 5, October, 2010.
10. Song, M., Kim, B., Ryu, Y., Kim, Y., and Kim, S., A design of real time control robot
system using android Smartphone‖ The 7th International Conference on Ubiquitous
Robots and Ambient Intelligence (URAI), Busan Korea, Nov. 2010.
11. Shilpa, V., Pradeep, H. S., and Kurian, M. Z., The Symbian Robot ‖ International
Journal of Computer Science and Informatics (IJCSI), Vol- 1, Issue-3.

Department of ECE, GEC Ramanagara. 51

You might also like