Building Automation System

You are on page 1of 67

Building automation system 2016

Abstract
With the advancement of technology things are becoming simpler and easier for us. The
automatic systems are preferred over manual system. This project focus on building
automation system (BAS) that provides an automatic improving and controlling features
to control several typical devices in building automatically , rather than manual means .
It also facilitates interaction among different electrical home appliances devices. Here in
our project we write a code and circuit diagram for temperature control system, automatic
light control system and door security system, on single PIC16f877A microcontroller
while for the software implementation, Micro C PRO for PIC has been used to interface
with the hardware. To implement this project it requires a less cost for initial investment.
This project successfully achieved main objective which enables us to automate devices
in an efficient way and to save energy in a single room until simulation.

[Type text] Page I


Building automation system 2016

Undertaking
We certify that project work titled building automation system is our own work. Where

material has been used from other sources it has been properly acknowledged referred.

Name of Student Signature Id.no

1. AHMED NASIR MUSTEFA ETR/014/04

2. GEDAMU AYENEW ETR/339/04

3. GETENESH LEMMA ETR/144/04

4. HAILEEYESUS MEKONEN ETR/278/04

5. ZEWDITU GEREMEW ETR/336/04

Electrical and computer engineering Page ii


Building automation system 2016

Acknowledgement
We give a great heart full thanks to almighty GOD for giving us strength and health from
beginning till now. Next we express our deepest gratitude to our advisor inst.
TALEGETA .M for his guidance to follow right way in our project work and his
unlimited advice .our appreciation and thanks also goes to our electrical and computer
engineering department team members for their emotional support , valuable information
and coordinal support throughout the year that they had given to us. We went to express
our deepest tanker for our family and friends for their support by providing what we
needand words can’t express our gratitude for all they have support us in our way

Electrical and computer engineering Page iii


Building automation system 2016

Electrical and computer engineering Page iv


Building automation system 2016

Table Contents
Abstract ............................................................................................................................. I
Acknowledgement ............................................................................................................ iii
Table of figure ............................................................................................................... vii
List of table ....................................................................................................................viii
1.2. Significant of the project ........................................................................................... 2
1.3. Statement of problem ............................................................................................... 2
1.4. Objective of the project............................................................................................. 2
1.4.1. General objective ............................................................................................... 2
1.4.2. Specific Objective .............................................................................................. 3
1.5. Scope of the project .................................................................................................. 3
1.6. Limitation of the project ........................................................................................... 3
1.7. Outlines of the project .............................................................................................. 3
2.2. Features of building automation system ...................................................................... 5
2.2.1. Automatic light control ....................................................................................... 5
2.2.2. Door security system .......................................................................................... 7
2.2.3.Temprature control system for single room ............................................................ 8
2.3. Components that we use in this project ....................................................................... 9
2.3.1. Hard ware component......................................................................................... 9
2.3.2. Software used .............................................................................................. 17
Chapter three................................................................................................................... 20
3. Design of project .......................................................................................................... 20
3.1. Design procedure ................................................................................................... 20
3.1.1. Design for automatic light control ...................................................................... 20
3.1.2. Design for temperature control system................................................................ 22
3.1.3. Design for door security system ......................................................................... 24
Chapter four .................................................................................................................... 27
4. Result and discussion.................................................................................................... 27
4.1. Simulation result of Automatic Light Control (ALC) .................................................. 27
4.2. Simulation result for Temperature Control System ..................................................... 31
4.3. Simulation result for Door Security System ............................................................... 33
Chapter five .................................................................................................................... 38
5. Conclusion and Rrecommendation ................................................................................. 38

Electrical and computer engineering Page v


Building automation system 2016
5.1. Conclusions........................................................................................................... 38
5.2 Recommendations................................................................................................... 39
References.................................................................................................................... 40
ABBREVATION ............................................................................................................ 41
APPENDIX A................................................................................................................ 42
APPENDIX B................................................................................................................. 44
APPENDIX C ................................................................................................................ 46
APPENDIX D ................................................................................................................ 48

Electrical and computer engineering Page vi


Building automation system 2016

Table of figure
Figure 1. LM35 connection .............................................................................................. 10
Figure 2. 3*4 keypad connection ...................................................................................... 13
Figure 3.pin connection of PIC16f877A ............................................................................ 14
Figure 4.16x2 LCD ......................................................................................................... 15
Figure 5. block diagram for automatic light control ............................................................. 21
Figure 6.flow chart for automatic light control ................................................................... 21
Figure 7. block diagram for temperature control system ...................................................... 23
Figure 8.flow chart of temperature control ......................................................................... 23
Figure 9.block diagram for door security system................................................................. 25
Figure 10. Flow chart for automatic door security system .................................................... 26
Figure 11.result 1 for automatic light control ..................................................................... 27
Figure 12.result 2 for automatic light control ..................................................................... 28
Figure 13.result for automatic light control ........................................................................ 29
Figure 14.result 4 for automatic light control ..................................................................... 30
Figure 15.result 1for temperature control ........................................................................... 31
Figure 16.result 2 for automatic light control ..................................................................... 32
Figure 17.result 1 result 1 for door security system ............................................................. 33
Figure 18.result 2 for door security system ........................................................................ 34
Figure 19.result 3 for automatic door security system.......................................................... 35
Figure 20.result 4 automatic door security system............................................................... 36
Figure 21.result 5 for automatic door security system.......................................................... 37

Electrical and computer engineering Page vii


Building automation system 2016

List of table
Table 1. Pin description of 16x2 LCD ............................................................................... 15
Table 2.pin description ULN2003A .................................................................................. 42
Table 3.pin description of PIC16f877A ............................................................................. 44

Electrical and computer engineering Page viii


Building automation system 2016

Chapter one
1. Introduction
1.1. Background
Building automation system provides an automatic control of the condition of indoor and
outdoor environments. Now a day, human have risen up their living standard due to rapid
economic expansion and development, a lot of buildings were built for educational
leisure and business purposes. All these buildings need modern control system in order to
make the building achieve their requirement. They require easy and modern system those
are building automation system in all these building for each single room.

Thus, building automation system has become an important system in building


establishment or management, it provides an automatic improving and controlling
features, to control several typical devices installed in building, rather than manual
means. It also facilitates the purpose of interaction among different devices.

The core application areas of building automation system cover several objectives;
however only three of them are discussed and are on our target to achieve in this project.
These three core areas are listed below and discussed.

1. Automatic light control system

Facilitates the purpose of automatic switching of electrical appliances rather than


manual means. Lighting control system can be used to control room electric lights. For
example, automatically extinguish lights in a room after if occupants enter a room.

2. Door security system

One of the most critical sensitive tasks under building automation system is safety and
security. It is very essential to keep on checking private zone where some specific
employees are only allow to enter. This access is controlled by using keypad.

Electrical and computer engineering Page 1


Building automation system 2016
Another aspect of building automation system includes a temperature and humidity
control. it make or control the temperature by detecting the room temperature with in a
range (i.e. T>27) it control the room temperature . This system is built to allow people
fully enjoy their home environment.

1.2. Significant of the project


The major significant of the project is

 It may decrease loss of power in building


 It may give simpler and easier service with advancement of technology
 Can help the building system is more secure by controlling the door security
system

1.3. Statement of problem


The main motivation behind this project is power wastage in large institution. We
observe a problem in large institution for example in office the light is on all the day
without break, due to this there is power loss in that room and also electrical equipment
lost. Therefore to solve this problem we design the light control system automatically
rather than manual means.

When the temperature is high so we get fan in many office and room this fan is on all the
day with high and low temperature and sometimes they forget to off this fan , due to this
the fan is not reliable or life span is short and there may be loss of power. To solve this
problem we design fan control system automatically.

In one office there is an equipment that is cost and to replace them it takes more time, but
usually we hear that those equipment lost and borrow by somebody, so to solve this
problem the office must be secure , due to this we design door security system to make
the room or office more secure.

1.4. Objective of the project


1.4.1. General objective
The general objective of this project is to manage or control and save electrical power in
the building that is consumed by using electrical equipment.

Electrical and computer engineering Page 2


Building automation system 2016

1.4.2. Specific Objective


 To control temperature automatically in order to maintain temperature
 To automatically control light to reduce power consumption
 To control door security system automatically

1.5. Scope of the project


Even though there is a lot of electrical equipment that have to be controlled on a single
building. The scope of the project is limited to design automation system for automatic
light control, temperature control and door security system.

 Design automatic light control system , temperature control


system and door security system using keypad
 Simulate design with appropriate software
 Implement and design for single room

1.6. Limitation of the project


 We implement the door security system we set password only four digit , but in
more features set pass word until 8 digit.
 We design the automatic light control, temperature control a door security system
only for single room.

1.7. Outlines of the project


This project contains five chapters; it covers all activities encounter during project work.

The first chapter briefly explains introduction, background information, statement of


problem, objective of the project, and scope of the project.

The second chapter summarizes literature review and history of building automation
system. The third chapter explains design methodology, description of block diagram
and flow chart of the systems briefly and some component used.

Electrical and computer engineering Page 3


Building automation system 2016
The forth chapter describe result and discussion of the project.

The last chapter five is all about conclusion and recommendation.

Electrical and computer engineering Page 4


Building automation system 2016

Chapter two
2. Literature review
2.1. History of building automation system
The term building automation system loosely used refers to any electrical control system
that is used to control a building heating , cooling , and ventilation system (HVAC)
modern building automation system can also control indoor and outdoor lighting as well
as security , fire alarms and basically everything else that is electrical in building on
either ac or dc wiring.

Building automation system provides automatic control of the condition of indoor


environments. The historical root and still core domains of this system is the automation
of heating ventilation and air conditioning system in large functional building. The
primary goal is saving in energy and reduces cost, yet its reach has extended to include
information from all kinds of building system.

It is centralize system, network of hard ware and software which monitor and control the
environment in commercial, industrial and institutional facilities while managing various
building system. Automation system ensures operational performance of facility as well
as comfort and safety building occupants. Typically such control systems are installed in
new building.

2.2. Features of building automation system


2.2.1. Automatic light control
According to different studies, around 40% of energy consumed globally is building
related. Artificial lighting consumes a significant part of all electrical energy consumed.
In offices 20 to 50% of total energy consumed is due to lighting. For some building 90%
of lighting energy consumed can be un-necessary expense through over illumination [1]

Someone switches on lights at the start and at the end of the day. other more sophisticated
building (few of them ) implement some sort of automatic control of lighting making this

Electrical and computer engineering Page 5


Building automation system 2016
switching on and off by automatic control based on presence detection , or colander
hourly basis and other even more sophisticated ones implement really effective lighting
control providing just appropriate light level in any part of building at any time ,having in
consideration many variable like day light coming from outside , presence of people in
each area , the required light level according to work places , etc.

It is obvious that more effective control we apply to lights in a building the more
comfortable. we will make it for people who spend a good part of their lives tree and of
course the more energy efficient we make the building itself with all benefits related to it
, reduction in electricity bill , maintenance budget , carbon foot print etc.

Lighting needs vary with the intended use (for example lighting offices , corridors ,
cubicles and training rooms) and characteristics of the area (such as room size and shape ,
ceiling height and availability of natural lights) most building condition more than one
type of lighting control system . On/off operation is an area where many designed create
a un workable lighting scheme.

In 2013 in Malaysiana university student whose name is NORIYAHIUT.A applied the


lighting control in hotel automatically. This system applied in large hotel that found in
Malaysia. This project successfully achieved the main objective which is able to control
light by using SMS and it definitely can save power because all the day it is not necessary
to on the light. This system applied for ground parking system. the method of this project
, first the client end his/ her name and id to the server using SMS , then the server send
back to microcontroller. In the same time, the microcontroller manages the light system
and server return the status to microcontroller. [2]

In our project we control light for single room. Our project is different from previous one
in that explained above is it control the light by sensing the number of people entering the
room and leaving the room. When the person enter in to the room it senses and on the
lights automatically by its own. This project is different from thee other project by it uses
the reserve switch which means when the person have no interest to on the light or if

Electrical and computer engineering Page 6


Building automation system 2016
something problem occurred in micro controller he/she use this reserved switch to
control the light

2.2.2. Door security system


When we think of locks, we think of a bolt containing a notch known as a talon, which is
operated by moving the bolt backwards or forward by engaging a key in the talon. But
there is more to locks than just a bolt or latch. A lock is a mechanical device that can be
usedfor securing doors, cabinets, lid of brief cases or other luggage . Itconsists
essentially of a bolt guarded by a mechanism which can be released by a
mechanical, hydraulic or electrical/electronic actuator.

The oldest known mechanical functioning lock was an Egyptian door lock used about
2000BC, made of wood and fastened vertically on the door post, the wooden block
contained moveable pins or “pin tumblers” that dropped by gravity into openings in the
cross piece of “bolts” and locked the door. It was operated by a wooden key with pegs
that raised the number of tumblers sufficiently to clear the bolt so that it could be pulled
back. The major disadvantage with it is that it was wholly made of wood. The Romans
made an improvement on this by fabricating the first metal locks which was later
improved by Robert Barson, an English man in 1778 and Linus Yale Jnr an American in
1861. The Yale lock consists of essentially a cylindrical plug placed in an outer barrel.
The plug is rotated and in turn moves the bolt of the lock by means of a cam. The inserted
key raises five pins of different sizes into corresponding holes in the plug.

The most common form of cylindrical lock used in homes is the so-called night latch,
operated from a key from outside and a knob from inside. In the 20th century, as machine
tools and manufacturing methods became more sophisticated, locks were produced,
which are either key operated (opened) or keyless. In the late 20thcentury,
electromechanical locks were developed to trip electrical circuit as seen in automobile
ignitions. Other keyless locks include remote controlled lock, “security card” operated
and electroniccs [3].

Electrical and computer engineering Page 7


Building automation system 2016

2.2.3.Temprature control system for single room


Temperature is a process in which temperature of an object is measured and the passage
of heat energy in to or out of the object is adjusted to achieve a desired temperature.
Electric fan is one of the most popular electricity appliances due to its cost effectiveness
and low power consumption advantages. It is a common circuit and widely used in many
applications. It is also one of the most sensible solution to offer comfortable and energy
efficient.

Nowadays, the usage of fan is controlled manually bypressing on the switch button. This
non-innovative featuremakes it unable to turn on automatically according totemperature
changes. So, an automatic temperature controlsystem technology is applied for the
switching purpose inthis circuit. Due to its advantages, many projects focusing on
automatic temperature control system application indifferent fields will gain the benefits.
For examples, anautomatic temperature controller for multielement arrayhyperthermia
systems,multi-loop automatic temperaturecontrol system design for fluid dynamics ,
automatic temperature control for transport airplanes , design of automatictemperature-
control circuit module in tunnel microwaveheating system , automatictemperature and
humidity control system using airconditioning in transformer substation and so
forth.There is also a case study of automatic temperature controlsystem on diagnosable
discrete event system design. This project proposes an invention of temprature control
system for a single rom. It has an automation operation by usinga microcontroller. It uses
a unique design. This is to enhance its functionality to become more efficient and
effective for hot weather condition. The circuit provides a comfort for human’s life,
especially for hot city. It really helps to solve the problem of handicapped personwhen to
switch on the fan.[4]
We can observe different works in temperature control system applied previously.
Temperature control for cooking system that is for stove applied in 2011 in Malaysia by
NORTHRAN .J a Malaysian university student. His method control the stove
temperature by using temperature sensor that senses the condition of stove and it takes
possible measure when temperature of stove going above or below specified value. This

Electrical and computer engineering Page 8


Building automation system 2016
control system also uses keypad control system and use also digital and sensing system.
[4]

In our project we also control the temperature this project is different from the above we
have seen is it control the temperature for single room. We control the room temperature
when the temperature is above 27 degree centigrade. In this system we use the
temperature sensor which senses the temperature and give signal to micro controller. This
system is different because it does not need any keypad the temperature sensor sense the
temperature and the fan on or off by its own and also when the person does not need the
fan or the temperature is become low degree centigrade there is heater that we proposed
to do.

2.3. Components that we use in this project


2.3.1. Hard ware component
1. Microcontroller

2. Temperature sensor

3. IR sensor

4. Liquid crystal display (LCD)

5. Motor driver

6. Relay

7. Relay driver

8. Keypad

2.3.1.1. Hardware component used in automatic light control


1. IR sensors

Infrared light is electromagnetic radiation with a wave length longer than that of visible
light s measured from nominal edge of visible red light, at 0.7 micrometers, and
extending conventionally to 300 micrometers. These wave length correspond to a
frequently range of approximately 1 to 430 THZ, and included most of thermal radiation

Electrical and computer engineering Page 9


Building automation system 2016
emitted by objects near room temperature. Microscopically, infrared light is typically
emitted o absorbed by molecules when they programing algorithm. Change their
rotational and vibrational movements.

2.3.1.2. Hardware component used for temperature control system


1. Temperature sensor

Temperature sensor is a sensor which converts the phenomena in to electrical output.


There are different kinds of temperature sensor in electrical world, but in our project we
use LM35 series temperature sensor. LM35 sensors are precision integrated circuit
temperature sensor used to detect ambient air temperature. It contain functional range
between ─40degreee Celsius to 150 degree Celsius and sensitivity is 10mv∕degree
Celsius. One of the important charactestics of LM35 is that it has an output voltage which
linearly proportional to Celsius temperature. It draws only 60Ua from its supply and
possesses a low self-heating capability which causes less than 0.1 c temperature rises in
still air.

The output voltage of a LM35 is proportional to the temperature in Celsius. LM35 sensor
is interfaced with microcontroller to measure room temperature vs. of the LM35 are
given to 5V and vout pins are given to AN0.

Figure 1. LM35 connection

2. Relay

A relay is electromagnetic switch, which activated when a small current is passed through
its coil. The interesting fact is that a small current is capable for turning on secondary
circuit which works on a much larger current. There are varieties of relay available in

Electrical and computer engineering Page 10


Building automation system 2016
electronic marked. Each of them operates at different voltage rating that will be energized
or trigger it.

A relay is an electrically controllable switch widely used in industrial controls,


automobiles and appliances. The relay allows the isolation of two separate sections of a
system with two different voltage sourcesWhen a current flow through the coil, a
magnetic field is created around the coil i.e., the coil is energized. This causes the
armature to be attracted to the coil. The armature’s contact acts like a switch and closes
or opens the circuit. When the coil is not energized, a spring pulls the armature to its
normal state of open or closed.

A relay consists of an electromagnet (coil), a switch, and a spring. The spring holds the
switch in one position until there is a current passed through the coil and then the
magnetic field is generated by the coil which moves the position of the switch.
Anyhow, it can be activated by a very small amount of current but the switch can handle
a lot of current.

The important part of relay is the coil. The coil makes the relay as an electromagnetic
switch. The principle of electro magnet is when a current carrying conductor induces a
magnetic field .if the conductor is covered around an iron core, the iron core becomes
magnetized. This is called electromagnet. The same principle is applied for relay too.
When a current pass via the relay coil the elector magnet is set up ad pulls one switch
contact away from other.

2.3.1.3. Hardware component used for automatic door security system


1. Motor driver

Motor driver is used to control motor through microcontroller. We use in this project
ULN2003A integrated motor driver. It is used as a motor driver. It provides logic to
control direction of motor. It is assembled in a 16 pin lead plastic package. This has 4
center pins connected together.

Electrical and computer engineering Page 11


Building automation system 2016

2. Relay driver

A relay driver is a high voltage and high current. It contains seven open collector pairs
.with common emitted. A pair is an arrangement of two bipolar transistors. It belongs to
family of ULN200x series of integrated circuit. These integrated circuit are used when
driving wide range of load and are used as relay drivers, display drivers, line driver etc. it
also commonly used while diving steeper motor.

3. 3x4 keypads

The 12 keys keypad is widely used in many applications, some of those are: telephones
and ATM machines. There are many different types of keypads and the keypad which
would be explained here would a matrix method in order to find which key is pushed.
This keypad does not have pins for Vdd or Vgnd, which means it does not require a direct
connection to a voltage source to perform its task. Also this keypad has 7-pins and each
pin would represent a row or a column. As this keypad has 12 key, it has 3 columns and
for rows. The mount of the keypad is as seen in which shows the dimension and pins
location.
The keypad has a 3-columns and 4-rows matrix orientation. If a key is pushed then the
circuit would be shorted for those specific key pins. The short circuit would always be
between a row pin and a column pin. For this specific 96AB2-152-F keypad the rows 1-4
are represented by pins 1-4 and columns 1-3 are represented by pins 5-7. For example
button 1 would be represented by pins 1 and 5, so if a voltage is applied to one of the pins
and a voltammeter is connected to the other pin, when the button is pushed the
voltammeter would read the input voltage.

Electrical and computer engineering Page 12


Building automation system 2016

Figure 2. 3*4 keypad connection

2.3.1.4. Hardware component commonly used for automatic light ,


temperature control and door security system
1. Microcontroller

The main controlling unit of proposed system is microcontroller. The main features of
microcontroller that is particularly PIC16F877A is discussed here. A microcontroller
consists of a powerful CPU tightly coupled with memory (RAM , ROM , EPROM),
various I/O feature such as serial port , portal port , timer/ counter ,interrupt controller ,
data requisition interface , analog to digital converter, digital to analog converter
everything integrated to single silicon chip . It does not mean that any micro controller
should have all the above features on a single chip.

Electrical and computer engineering Page 13


Building automation system 2016

Figure 3.pin connection of PIC16f877A

2. Liquid crystal display (LCD)

Liquid crystal display (LCD) is a flat panel display, electronic visual display, or video
display that uses the light modulating properties of liquid crystals. Liquid crystals do not
emit light directly. LCDs are available to display arbitrary images (as in a general-
purpose computer display) or fixed images which can be displayed or hidden, such as
preset words, digits, and 7-segment displays as in a digital clock. They use the same basic
technology, except that arbitrary images are made up of a large number of small pixels,
while other displays have larger elements.
A 16x2 LCD means it can display 16 characters per line and there are 2 such lines. In this
LCD each character is displayed in 5x7 pixel matrix. This LCD has two registers,
namely, Command and Data. The command register stores the command instructions

Electrical and computer engineering Page 14


Building automation system 2016
given to the LCD. A command is an instruction given to LCD to do a predefined task like
initializing it, clearing its screen, setting the cursor position, controlling display etc. The
data register stores the data to be displayed on the LCD. The data is the ASCII value of
the character to be displayed on the LCD.
PIN DESCRIPTION OF LCD
The most commonly used LCDs found in the market today are 1Line, 2Line or4 Line
LCD switch have only1 controller and support at most of 80 characters, whereas LCD
supporting more than 80characters make use of 2HD44780 controllers. Most LCD switch
1 controller has 14 Pins and LCDs with 2 controller has16 Pins (two pins are extraind
both for back-light LED connections).Pin description is shown in the table below,

Figure 4.16x2 LCD

Table 1. Pin description of 16x2 LCD

Pin No Function Name


1 Ground Ground
2 Supply voltage,5v(4.7v-5v) VCC
3 Contrast adjustment ,through variable resistor VEE
4 Select command register ,when low ,data register when Register select
5 high Read/write
6 Low to write to register , high to read from register Enable
7 Send data to data pins when high to low pulse is given DB0
8 DB1
9 DB2

Electrical and computer engineering Page 15


Building automation system 2016

10 DB3
11 DB4
8 bit data pins
12 DB5
13 DB6
14 DB7
15 Backlight VCC(5v) LED+
16 Backlight ground(0v) LED-

B. Register select:

It decides either command code register is selected or data register is selected. If Rs꞊0, it
will select the command register to send command to the LCD otherwise data register
will be selected.

C. Read ∕write (R∕W):

This input pin is used to determine either data is going to write on the LCD to read from
it. If R∕W꞊1 means data regarding while R∕W꞊0 data is going to be write on LCD

D. Enable:

In order to latch in information presented to its data pin, enable (E), pin is used; high low
pulse must be applied to the e pin for latching purpose.

E. Data bus (D0-D7):

Information is sent to read through data bus depending up on to registers gives selection
pin status, as described earlier. ASCI code is sent to either command or display the data.
Different command codes are used to perform different tasks.

2.3.1.5. Interfacing keypad with PIC microcontroller


We interface keypad with PIC microcontroller with some user defined function. The
micro c pro for PIC microcontroller provides a library for working with 4*3 keypad.In
this example, the used microcontroller is PIC16f877A, so some other microcontrollers
might have some different requirements or setting in the code, however the method is set

Electrical and computer engineering Page 16


Building automation system 2016
to be general so it could be used in any microcontroller that have the appropriate pins and
settings. Also, some important parameter should be set in advance to find which key is
pushed. First the microcontroller pins that are connected to the rows should be set to be
high output pin, and the column pins should be set to be input pins. Then in order to
detect if a pin is pushed the microcontroller would set one row output to be low and then
try to detect if it receives a low input from the column of the keypad. Then, it would set
that row back to high and set another row to low, that would happen until it detects the
low signal and convert that signal into a key character. This loop would happen in a
matter of microseconds so if a button is pushed it would detect it easily.

For example: if button `8' is pushed the microcontroller would set the first row to low,
then detect if an input goes low, which none would because `8' is connected to row 3
which is high and then the shorted output between column 2 and row 3 would still be
high. Then the microcontroller will reset row 1 to high and set row 2 to low, which would
not change any input. Then, the microcontroller would reset row 2 to high and set row 3
to low, and try to detect if one of the columns inputs is low, which the 2nd column would
be low, because when `8' is pressed column 2 would be shorted with row 3 and since row
3 is low, and column 2 is connected to it and to a pull up resistor, the resistor would pull
the voltage away from the pin of column 2 which makes the microcontroller detects a low
input in column 2 when row 3 is set to low, then it would now that `8' is pressed.

2.3.2. Software used


2.3.2.1. Proteus
Proteus is software for microprocessor simulation, schematic capture, and printed circuit
board (PCB) design. It is developed by Lab center Electronics. The X Game Station
Micro Edition was designed using Lab center Proteus schematic entry and PCB layout
tools
Proteus PCB design combines the ISIS schematic capture and ARES PCB layout
programs to provide a powerful, integrated and easy to use suite of tools for professional
PCB Design. All Proteus PCB design products include an integrated shape based auto
router and a basic SPICE simulation capability as standard.

Electrical and computer engineering Page 17


Building automation system 2016
More advanced routing modes are included in Proteus PCB Design Level 2 and higher
whilst simulation capabilities can be enhanced by purchasing the Advanced Simulation
option and/or micro-controller simulation capabilities.
System components
 ISIS Schematic Capture - a tool for entering designs.
 PROSPICE Mixed mode SPICE simulation - industry standard SPICE3F5
simulator combined with digital simulator.
 ARES PCB Layout - PCB design system with automatic component placer, rip-up
and retry auto-router and interactive design rule checking.
 VSM - Virtual System Modeling lets simulate embedded software for popular
micro-controllers alongside hardware design.
 System Benefits Integrated package with common user interface and fully context
sensitive help.

2.3.2.2. MIKRO C

MIKROC is a full-featured ANSI C compiler that is available for six different


microcontroller architectures (in this case, for PIC 12/16/18). It features an intuitive IDE,
a powerful compiler with advanced SSA optimizations, lots of hardware and software
libraries, and additional tools that will help you in your work. The compiler comes with a
comprehensive Help file (700 pages) and lots of ready-to-use examples designed to get
you started in no time. Each compiler license includes free upgrades and tech support for
the lifetime of the product. The software features a Live Update service so you can get
new features and improvements instantly. The MIKROC PRO for PIC compiler supports
504 PIC microcontrollers. Newly released PIC microcontroller will be supported by new
versions of the compiler software that is updated regularly. The compiler is designed to
be smart and efficient, so you can rely on it to do the hard work. It features four levels of
optimizations that can reduce your code size up to 20 percent. Standard header files are
included that make it easy to port your code from other C compilers.

2.3.2.2.1. MIKROC PRO for PIC Compiler features


 Single-click Debugging

Electrical and computer engineering Page 18


Building automation system 2016
MIKRO PRO for PIC has native support for the micro ICD In-Circuit Debugger feature
of the fast USB2.0 MIKRO Prog-PIC programmer (in both on-board and standalone
versions). MIKROICD is a separate DLL module which supports Step-over, Step-Into,
Step-Out, Run, and Run-to-Cursor debugging operations. Also, the debugger supports
standard and advanced breakpoints.
 Faster, better, more productive
MIKROC PRO for PIC comes equipped with fully functional software tools that can
boost your efficiency and do the job for you, so you can be more productive in your
work: LCD Custom Character Tool, GLCD
Bitmap Editor, Seven-Segment Editor, UART Terminal, UDP Terminal, HID Terminal,
ASCII Chart, Active Comments Editor, Advanced Statistics and more.

Electrical and computer engineering Page 19


Building automation system 2016

Chapter three

3. Design of project
We construct, design and develop block and circuit diagram to automatic light control,
temperature control system and door security system, on a single PIC16f877A by using
PROTUS. The software is developed by having flowchart and specifying the condition to
be implemented in MIKROC. The code is written on the PIC16F877A to integrate all
features that is to be included in the building automation system.

To develop the building automation system circuit; electronic equipment such as sensors
(IR sensor, temperature sensor), capacitor, LCD, motor driver, transistor and
microcontroller are used. Comparison and discussion of the result from design with
expected result is done and the suggested model is justified with direction of future work
is clearly pointed out in this methodology and finally the project report is written
including PROTEUS simulation output results.

3.1. Design procedure


3.1.1. Design for automatic light control
Automatic light control facilitates purpose of automatic switching of electrical appliances
rather than manual means. Infrared sensor will help to accomplish this task .two sensors
are installed. Two sensors are installed at two doors that are entrance and exit. Sensors
increment the counter when any person enters through the entrance door and signal is
given to decrement the counter after sensing the person leaving the room trough exit
door. Current value of the counter determines the status of electricity either powered ON
or OFF. If anyone is inside the room the counter.

3.1.1.1. Block diagram description for automatic light control


The two IR sensor increment and decrement when any person enters through the door and
exit and give a signal to microcontroller. The micro controller sends a command to
display a signal that IR sensors count and display the status of lamp.

Electrical and computer engineering Page 20


Building automation system 2016

LCD
interface

IR PIC16F877A
sensor
Switch

Figure 5. Block diagram for automatic light control

3.1.1.2. Flow chart description for automatic light control


Signal from infrared sensors are given to bits of the controller and these signals decide
either to decrement or increment the counter. If counter values equal to 1 or greater than
1, signal will be generate to energize the and it will turn on the supply and when counter
values is 0 it de energize and so that light is glow

Start

Yes No
While
loop

Yes No No
Count+
Count--
+
Count>0
Count>0
Light off

Light on Light on

Figure 6.flow chart for automatic light control

Electrical and computer engineering Page 21


Building automation system 2016

3.1.1.3. Automatic light control circuit operation


The two IR sensors, which are placed on entrance and exit. The person who are entering
or leaving the room the frequency in sensor are disturbed , then the counter starts to count
the number of people are entering and leaving the room . Here, two push button are used
in place of infrared sensors. The one acts as entrance where the second push button acts
as exit push button. When we press push button 1, the counter begins to count and the
light becomes glow. When we press second push button 2 the value of the counter is
decremented. When the value of the counter after decremented become zero the light
become to off state.

The LCD will display number of people who are entering and leaving the room and state
of lights, whether the lights on /off. In case at which some problems happen for instance
when the sensor or microcontroller fail to operate and if a person wants to operate the
lights manually the reserved switch are used to make light turn off.

3.1.2. Design for temperature control system


Once the person is entering the room he/she would not require switching on anything.
Everything will just happen automatically. Like if temperature is high, the fan will switch
on, on its own. Else it will remain off state. This temperature predefined by controller.

3.1.2.1. Block diagram for temperature control system


The design system described by below block diagram. It consists of LCD
which displays the temperature that read or sense by the temperature sensor ,
the temperature sensor read and sense the temperature and send command to
micro controller ,the micro controller send command to LCD after sensing
the temperature the cooling fan start to rotate

Electrical and computer engineering Page 22


Building automation system 2016

Temperature
sensor
LCD

PIC16F877A
Cooling
fan

Figure 7. block diagram for temperature control system

3.1.2.2. Flow chart description for temperature control system


The PIC16F877Awith internal analog digital converter read the analog voltage from
temperature sensor (LM3S) and display. Depending on temperature setting in micro
controller the fan starts to operate to keep room temperatu.

Start

Read
temperature

If T>27

No Yes

Fan on
Fan off

Figure 8.flow chart of temperature control

Electrical and computer engineering Page 23


Building automation system 2016

3.1.2.3. Circuit diagram operation for temperature control system


The temperature sensor (LM35) senses the amount of temperature inside the room (living
room, office, shop, hall, café and like), and it will send analog signal to PIC16F877A.
The PIC has built in analog digital converter (ADC) converts analog input from LM35 in
to digital signal to carry out the program written in microcontroller. The fan starts to
operate when temperature exceeds above room temperature. The LCD interfaced to micro
controller used to display current value of LM35 sensed from the environment. The micro
controllers understand the temperature by their own language. The temperature can be
calculated by using slope formula.

Let the temperature value is 27 degrees centigrade, the micro controller understand this
temperature as a 56.

3.1.3. Design for door security system


One of the most critical sensitive tasks under building automation system is safety and
security. It is very essential to keep on checking the private zone areas where some
specific employees are only to enter. Their access is controlled by using keypad. It is
directly connected to microcontroller. It is working based on its programing rather than
external circuitry. The door at which keypad is connected will open only when employee
will enter right code. Its code is programed in such a way that manager or security officer
can change the code externally without changing the software of microcontroller.

In this system we have ensured a safe locking system. From outside the lock would not
be visible but this in built locking system ensures security. This lock can be opened and
closed with the help of a password which we will give using a keypad. The door will
open or close only if the password is correct else it will remain in its original state. The
lock cannot be broken because to the person standing outside can just see closed door and
not the lock as it is in built. The password is given with the help of controller and can
change by simply making a small change in program and then the program in controller.

3.1.3.1. Block diagram description of door security system


The operation of this system can be described by below block diagram, which consists of
block as keypad, an LCD, This block gives Entered code signal to the microcontroller.

Electrical and computer engineering Page 24


Building automation system 2016
The steeper motor moves the door, opens the door and closes the door and motor driver
drives the motor by receiving control signal from micro controller

LCD

ULN2003A Door lock


Keypad PIC16F877A

Figure 9.block diagram for door security system

3.1.3.2. Flow chart for door security system


The flow diagram describes when a person enters a password by using various key in the
keys in the keypad ranging from 0 to 9 including enter and escape keys. And the
microcontroller immediately reads the data and compares it with the stored data in
microcontroller.

First, microcontroller which is interfaced with LCD display a word which says press
*key. If this when we press the key(*) button , the microcontroller sends display
information to the LCD display as enter password and after we enter a password the LCD
displays that the password is reset which is “password set”, when we enter the reset
password Furthermore, the microcontroller sends the command signal to motor driver to
rotate the motor driver integrated circuit to rotate the motor in particular direction such
that the door opens at the same time LCD display DOOR OPENS after some time of
delay, and then door starts closing from command it gets from microcontroller and after
door closed LCD displays DOOR CLOSED after ensuring the door is closed it go back
again to start.

If the people attempts may be forget the password by using the reset password he or she
can create their own password, so this enables the system or password is not steal by
others. Sometimes some systems like this use only or sold with password which set by

Electrical and computer engineering Page 25


Building automation system 2016
the manufactured industry this effect the customer limit by the manufacturer password
and it may have a probability steal by other

Start

Password incorrect Display Password correct


press *
key

Set password

Wrong
password

Delay
Password
set

DOOR
OPEN

DOOR
CLOSED

Figure 10. Flow chart for automatic door security system

Electrical and computer engineering Page 26


Building automation system 2016

Chapter four

4. Result and discussion


4.1. Simulation result of Automatic Light Control (ALC)
1. Initially when both bush button 1 and 2 are open, the LCD display counter=0 and
light = 0 which means there is no person etheir entring or exiting the room.
Push button one open

LCD1
LM016L

C1 +12v

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
22pf

X1
CRYSTAL
C2
U1
22pf 13 33
OSC1/CLKIN RB0/INT
14 34
OSC2/CLKOUT RB1 +12v
35
RB2
2 36
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
+5v RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
+5v RC0/T1OSO/T1CKI
8 16
9
RE0/AN5/RD RC1/T1OSI/CCP2
17 L1
RE1/AN6/WR RC2/CCP1 12V
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
RD2/PSP2
21 Q1
22 2N2369
RD3/PSP3
27
RD4/PSP4
R3 RD5/PSP5
28
10k 29
RD6/PSP6
30
RD7/PSP7
R4
10k PIC16F877A

Push button two open Lamps off state

Figure 11.result 1 for automatic light control

Electrical and computer engineering Page 27


Building automation system 2016
2.When the push button 1 pressed at second condition counter increase which means
let 13 peoples are already, entered into the room .at the initial of the increment
(counter from 0 to 1) the light glow .where light display on LCD reads light 1 and
counter displays 13 people.

Pushbuttonone closed counter increment

LCD1
LM016L

C1 +12v

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
22pf

X1
CRYSTAL
C2
U1
22pf 13 33
OSC1/CLKIN RB0/INT
14 34
OSC2/CLKOUT RB1 +12v
35
RB2
2 36
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
+5v RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
+5v RC0/T1OSO/T1CKI
8 16
9
RE0/AN5/RD RC1/T1OSI/CCP2
17 L1
RE1/AN6/WR RC2/CCP1 12V
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
RD2/PSP2
21 Q1
22 2N2369
RD3/PSP3
27
RD4/PSP4
R3 RD5/PSP5
28
10k 29
RD6/PSP6
30
RD7/PSP7
R4
10k PIC16F877A

Lamp glow

Figure 12.result 2 for automatic light control

Electrical and computer engineering Page 28


Building automation system 2016
3. When push button two pressed the counter value is decreases by 1 i.e. from 13 to
12. Which means one person was exit from the room. Even though, the person
exits the lamp is still ON.

Counter decrement by 1

LCD1
LM016L

C1 +12v

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
22pf

X1
CRYSTAL
C2
U1
22pf 13 33
OSC1/CLKIN RB0/INT
14 34
OSC2/CLKOUT RB1 +12v
35
RB2
2 36
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
+5v RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
+5v RC0/T1OSO/T1CKI
8 16
9
RE0/AN5/RD RC1/T1OSI/CCP2
17 L1
RE1/AN6/WR RC2/CCP1 12V
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
RD2/PSP2
21 Q1
22 2N2369
RD3/PSP3
27
RD4/PSP4
R3 RD5/PSP5
28
10k 29
RD6/PSP6
30
RD7/PSP7
R4
10k PIC16F877A

Pushbutton closed lamp glow

Figure 13.result for automatic light control

Electrical and computer engineering Page 29


Building automation system 2016
4. When push button two is pressed until the counter value becomes zero that is the
last person is exists from the room. The light turns to OFF state.

Counter zero

LCD1
LM016L

C1 +12v

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
22pf

X1
CRYSTAL
C2
U1
22pf 13 33
OSC1/CLKIN RB0/INT
14 34
OSC2/CLKOUT RB1 +12v
35
RB2
2 36
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
+5v RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
+5v RC0/T1OSO/T1CKI
8 16
9
RE0/AN5/RD RC1/T1OSI/CCP2
17 L1
RE1/AN6/WR RC2/CCP1 12V
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
RD2/PSP2
21 Q1
22 2N2369
RD3/PSP3
27
RD4/PSP4
R3 RD5/PSP5
28
10k 29
RD6/PSP6
30
RD7/PSP7
R4
10k PIC16F877A

Push button 2 till closed lamp off

Figure 14.result 4 for automatic light control

Electrical and computer engineering Page 30


Building automation system 2016

4.2. Simulation result for Temperature Control System


1.The LM35 reads the temperature from the environment and give to the
microcontroller which in turn sends a command to LCD to display the amount of
temperature. Here, the temperature is less than 27 degree Celsius so that fan does not
drive.
LCD displays 22.celcius

LCD1
LM016L
+5v

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
R1
10k

U1
13 33
OSC1/CLKIN RB0/INT
14 34
OSC2/CLKOUT RB1
35
RB2 +12v
2 36
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7 R2
RA5/AN4/SS/C2OUT
U2 RC0/T1OSO/T1CKI
15 R3
1 8 16 10k 10k
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
21.0 RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
RC6/TX/CK
25 Q1 RL1
2 26 BC547 12V
VOUT RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
3 LM35 21
RD2/PSP2
22
RD3/PSP3
27
RD4/PSP4 +12v
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7
PIC16F877A

LM35 senses temperature 22.celcius fan not rotate

Figure 15.result 1for temperature control

Electrical and computer engineering Page 31


Building automation system 2016

2.The LM35 senses the temperature which is greater than room temperature, during this
time the LCD displays the amount of temperature read by the sensor and also sends a
command to activate the fan in order to rotate it to maintain the room temperature.

LCD displays .37celcius

LCD1
LM016L
+5v

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
R1
10k

U1
13 33
OSC1/CLKIN RB0/INT
14 34
OSC2/CLKOUT RB1
35
RB2 +12v
2 36
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT R2
U2 RC0/T1OSO/T1CKI
15 R3
1 8 16 10k
RE0/AN5/RD RC1/T1OSI/CCP2 10k
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
37.0 RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
RC6/TX/CK
25 Q1 RL1
2 26 BC547 12V
VOUT RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
3 LM35 21
RD2/PSP2
22
RD3/PSP3
27
RD4/PSP4 +12v
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7
PIC16F877A

LM35 sense temp.37celcius fan rotate

Figure 16.result 2 for automatic light control

Electrical and computer engineering Page 32


Building automation system 2016

4.3. Simulation result for Door Security System


1 .Initially the micro controller sends a command to LCD to display’’press key
LCD display

LCD1
LM016L

C1 RP1
1

22pF 2

VDD
VSS

VEE
3

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
4
U1 5

1
2
3

4
5
6

7
8
9
10
11
12
13
14
X1 13
OSC1/CLKIN RB0/INT
33 6
CRYSTAL 14 34 7
OSC2/CLKOUT RB1
35 8
RB2
2 36
C2 RA0/AN0 RB3/PGM
3 37 RESPACK-7
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5 +5v
5 39
+5v RA3/AN3/VREF+ RB6/PGC
22pF 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
+5v
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9
U2
9
1
1B
COM
1C
16
D 0 #
2 15
2B 2C
3 14
3B 3C
4 13 0.00
4B 4C
5 12
5B 5C
6 11
6B 6C
7 10
7B 7C
ULN2003A

Figure 17.result 1 result 1 for door security system

Electrical and computer engineering Page 33


Building automation system 2016
2. When password inserted to micro controller by using key pad , it understand any
set password we enter and micro controller send a command to LCD which display
set pwd

LCD display

LCD1
LM016L

C1 RP1
1

22pF 2

VDD
VSS

VEE
3

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
4
U1 5

1
2
3

4
5
6

7
8
9
10
11
12
13
14
X1 13
OSC1/CLKIN RB0/INT
33 6
CRYSTAL 14 34 7
OSC2/CLKOUT RB1
35 8
RB2
2 36
C2 RA0/AN0 RB3/PGM
3 37 RESPACK-7
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5 +5v
5 39
+5v RA3/AN3/VREF+ RB6/PGC
22pF 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
+5v
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9
U2
9
1
1B
COM
1C
16
D 0 #
2 15
2B 2C
3 14
3B 3C
4 13 0.00
4B 4C
5 12
5B 5C
6 11
6B 6C
7 10
7B 7C
ULN2003A

Figure 18.result 2 for door security system

Electrical and computer engineering Page 34


Building automation system 2016
3. When we inserted to microcontroller by keypad, it compares the password
with set password with entered password, if it is match, after some delay the
microcontroller send command to motor driver to rotate motor clock wise to
open the door.

LCD display door open

LCD1
LM016L

C1 RP1
1

22pF 2

VDD
VSS

VEE
3

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
4
U1 5

1
2
3

4
5
6

7
8
9
10
11
12
13
14
X1 13
OSC1/CLKIN RB0/INT
33 6
CRYSTAL 14 34 7
OSC2/CLKOUT RB1
35 8
RB2
2 36
C2 RA0/AN0 RB3/PGM
3 37 RESPACK-7
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5 +5v
5 39
+5v RA3/AN3/VREF+ RB6/PGC
22pF 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
+5v
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9
U2
9
1
1B
COM
1C
16
D 0 #
2 15
2B 2C
3 14
3B 3C
4 13 +315
4B 4C
5 12
5B 5C
6 11
6B 6C
7 10
7B 7C
ULN2003A

Motor rotate clock wise

Figure 19.result 3 for automatic door security system

Electrical and computer engineering Page 35


Building automation system 2016
4. After some delay the LCD displays the microcontroller send command to motor
driver to rotate motor antilock wise to close the door and LCD displays “door
closed”.

LCD display door close

LCD1
LM016L

C1 RP1
1

22pF 2

VDD
VSS

VEE
3

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
4
U1 5

1
2
3

4
5
6

7
8
9
10
11
12
13
14
X1 13
OSC1/CLKIN RB0/INT
33 6
CRYSTAL 14 34 7
OSC2/CLKOUT RB1
35 8
RB2
2 36
C2 RA0/AN0 RB3/PGM
3 37 RESPACK-7
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5 +5v
5 39
+5v RA3/AN3/VREF+ RB6/PGC
22pF 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
+5v
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9
U2
9
1
1B
COM
1C
16
D 0 #
2 15
2B 2C
3 14
3B 3C
4 13 +304
4B 4C
5 12
5B 5C
6 11
6B 6C
7 10
7B 7C
ULN2003A

Motor rotate anti clock wise

Figure 20.result 4 automatic door security system

Electrical and computer engineering Page 36


Building automation system 2016
5. When we inserted to micro controller by keypad, it compare the stored password
with entered password if it is not match, microcontroller send command LCD which
displays “wrong password”

LCD display wrong password


.

LCD1
LM016L

C1 RP1
1

22pF 2

VDD
VSS

VEE
3

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
4
U1 5

1
2
3

4
5
6

7
8
9
10
11
12
13
14
X1 13
OSC1/CLKIN RB0/INT
33 6
CRYSTAL 14 34 7
OSC2/CLKOUT RB1
35 8
RB2
2 36
C2 RA0/AN0 RB3/PGM
3 37 RESPACK-7
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5 +5v
5 39
+5v RA3/AN3/VREF+ RB6/PGC
22pF 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20

3
RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
+5v
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9
U2
9
1
1B
COM
1C
16
D 0 #
2 15
2B 2C
3 14
3B 3C
4 13 0.00
4B 4C
5 12
5B 5C
6 11
6B 6C
7 10
7B 7C
ULN2003A

Figure 21.result 5 for automatic door security system

Electrical and computer engineering Page 37


Building automation system 2016

Chapter five

5. Conclusion and Rrecommendation


5.1. Conclusions
This achievement of controlling different task by using a single controller enables us to
automate devices in an efficient and effective way.

In automatic light control system we conclude that the design of automatic light control
system is to decrease power consumption by light and ensure the time availability of
equipment because in building large amount of energy used from each office , house. So
we use light automatically it save that energy.

Automatic temperature control systems fulfill the desire area in this project. By automatic
temperature control system we maintain the temperature of environment by comparing
room temperature automatically by using fan system. This system generally use their
environment effectively and efficiently and able to user recreate their environment.

Automatic door security system provides the desire area which is security and safety. In
this system the manufacturer sell the system with reset password this enables that the user
set their own password and use this password. This enables to user able to open the door
when he/she forget the password and it protect the password from theft.

The major purpose of designing and implementation this controlling strategy is to save
energy which is the most important phase, because in many power plant or process and
manufacturing plants large amount of energy is used.Generally, the overall Building
Automation System is meets it objectives by the developed program MIKRO C and
circuit diagram by PROTEUS. The operation is functioning accordingly and smoothly
following the procedure taken. The circuit has fulfilled the main objectives, which are
automatic light control, fan control system and door security system according to the
desire.

Electrical and computer engineering Page 38


Building automation system 2016

5.2 Recommendations
We strongly recommend that these projects should be used at commercial as well as
domestic levels not only to save energy but also to provide safe security system and make
life easy.

We recommend for Construction Company to give more emphasis for building


automation system. To enable the building that construct in this century effectively and
efficiently their equipment and make the life of customer and also the service easy, to
save energy the automatic control for light, door and temperature preferable to construct
in those building.

We would also like to recommend the department of Electrical and Computer


Engineering to prepare hardware equipment needed to implement the project. And we
also recommend that the software give briefly to students this project is important in this
time because everything goes with security so if the students are familiar with this
software like proteus and MIKROC they practice easily and prepare a project in different
aspect. We also recommend that in laboratory in laboratory that software should install
correctly on the computer and modify every time by lab assistance that are familiar with
those software.

Electrical and computer engineering Page 39


Building automation system 2016

References
[1].http://www.ecnweb.com/mag/electric.lighting control/index seen at May 2016 at 9
o’clock

[2] http://www.schnider-electric.co.uk seen at April 2016

[3] www.ijnet volume 2 Issue9, September 2013

[4] http://eikipidia.org/wiki/universal at 6th April

Electrical and computer engineering Page 40


Building automation system 2016

ABBREVATION
ADC……………………………Analog Digital Converter

ALC……………………………Automatic Light Control

BAS…………………………….Building Automation System

CPU…………………………….Central processing unit

HVAC……………………………heating ventilation and cooling system

I/O………………………………. input output

PCB………………………………programmable circuit board

RAM………………………………Random Access Memory

ROM………………………………Read Only Memory

Electrical and computer engineering Page 41


Building automation system 2016

APPENDIX A

Table 2.pin description ULN2003A

Pin no Function Name


st
1 Input for 1 channel Input 1
2 Input for 2nd channel Input 2
3 Input for 3rd channel Input 3
4 Input for 4th channel Input 4
5 Input for 5th channel Input 5
6 Input for 6th channel Input 6
7 Input for 7th channel Input 7
8 Ground (0V) Ground
9 Common free wheeling diodes Common
10 Input for 7th channel Input 7

Electrical and computer engineering Page 42


Building automation system 2016

11 Input for 6th channel Input 6


12 Input for 5th channel Input 5
13 Input for 4th channel Input 4
14 Input for 3rd channel Input 3
15 Input for 2nd channel Input 2

Electrical and computer engineering Page 43


Building automation system 2016

APPENDIX B

Pin lay out table PIC16F877A


Table 3.pin description of PIC16f877A

Pin name Dip PLCC I/O/O BUFFER DESCRIPTION QFP


pin# pin# TYPE TYPE
Osc/clink 13 14 1 St/cmos Osc/crystal
Osc clkout 14 15 0 - i/p. osc. crystal
o/p
MCLR/VSS 1 2 i/p St Master clear i/p
or program i/p
RA0/AN0 2 3 I/O TTL Port A is bi
RA1/AN1 3 4 I/O TTL directional
RA2/AN2/VREF- 4 5 I/O TTL
RA3/AN3/VREF+ 5 6 I/O TTL
RA4/AN4 6 7 I/O SL
RA5/S5/AN4 7 8 I/O TTL

Electrical and computer engineering Page 44


Building automation system 2016

RB0/INS 33 36 I/O TTL/ST1 Portb is bi


RB1 34 37 I/O TTL directional i/o
RB2 35 38 I/O TTL port.portb can be
RB3/PGM 36 39 I.O TTL s/w pgreed for
RB4 37 41 I/O TTL pull up
RB5 38 42 I/O TTL
RB6/PGC 39 43 I/O TTL/ST2
RB7/PGD 40 44 I/O TTL/ST2

Electrical and computer engineering Page 45


Building automation system 2016

APPENDIX C
Circuit diagram for automatic light

LCD1
LM016L

C1 +12v

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
22pf

X1
CRYSTAL
C2
U1
22pf 13 33
OSC1/CLKIN RB0/INT
14 34
OSC2/CLKOUT RB1 +12v
35
RB2
2 36
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
+5v RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
+5v RC0/T1OSO/T1CKI
8 16
9
RE0/AN5/RD RC1/T1OSI/CCP2
17 L1
RE1/AN6/WR RC2/CCP1 12V
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
RD2/PSP2
21 Q1
22 2N2369
RD3/PSP3
27
RD4/PSP4
R3 RD5/PSP5
28
10k 29
RD6/PSP6
30
RD7/PSP7
R4
10k PIC16F877A

Electrical and computer engineering Page 46


Building automation system 2016

Circuit diagram for automatic temperature control system

LCD1
LM016L
+5v

VDD
VSS

VEE

RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E
1
2
3

4
5
6

7
8
9
10
11
12
13
14
R1
10k

U1
13 33
OSC1/CLKIN RB0/INT
14 34
OSC2/CLKOUT RB1
35
RB2 +12v
2 36
RA0/AN0 RB3/PGM
3 37
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5
5 39
RA3/AN3/VREF+ RB6/PGC
6 40
RA4/T0CKI/C1OUT RB7/PGD
7 R2
RA5/AN4/SS/C2OUT
U2 RC0/T1OSO/T1CKI
15 R3
1 8 16 10k 10k
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
26.0 RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
RC6/TX/CK
25 Q1 RL1
2 26 BC547 12V
VOUT RC7/RX/DT
19
RD0/PSP0
20
RD1/PSP1
3 LM35 21
RD2/PSP2
22
RD3/PSP3
27
RD4/PSP4 +12v
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7
PIC16F877A

Circuit diagram for automatic door security system

LCD1
LM016L

C1 RP1
1

22pF 2
VDD
VSS

VEE

3
RW
RS

D0
D1
D2
D3
D4
D5
D6
D7
E

4
U1 5
1
2
3

4
5
6

7
8
9
10
11
12
13
14

X1 13
OSC1/CLKIN RB0/INT
33 6
CRYSTAL 14 34 7
OSC2/CLKOUT RB1
35 8
RB2
2 36
C2 RA0/AN0 RB3/PGM
3 37 RESPACK-7
RA1/AN1 RB4
4 38
RA2/AN2/VREF-/CVREF RB5 +5v
5 39
+5v RA3/AN3/VREF+ RB6/PGC
22pF 6 40
RA4/T0CKI/C1OUT RB7/PGD
7
RA5/AN4/SS/C2OUT
15
RC0/T1OSO/T1CKI
8 16
RE0/AN5/RD RC1/T1OSI/CCP2
9 17
RE1/AN6/WR RC2/CCP1
10 18
RE2/AN7/CS RC3/SCK/SCL
23
RC4/SDI/SDA
1 24
MCLR/Vpp/THV RC5/SDO
25
RC6/TX/CK
26
RC7/RX/DT
19
RD0/PSP0
20
1

RD1/PSP1
21
RD2/PSP2
22
RD3/PSP3
RD4/PSP4
27
+5v
A 1 2 3
28
RD5/PSP5
29
RD6/PSP6
30
RD7/PSP7 B 4 5 6
PIC16F877A

C 7 8 9
U2
9
1
1B
COM
1C
16
D 0 #
2 15
2B 2C
3 14
3B 3C
4 13 +88.8
4B 4C
5 12
5B 5C
6 11
6B 6C
7 10
7B 7C
ULN2003A

Electrical and computer engineering Page 47


Building automation system 2016

APPENDIX D
Program code for each system
1. Code for automatic light control system
int TO ,str , people=0, ADCON ,FF;
int sw , light=0, counter=0;
int txt[10],txt1[10];
int n,m;
ADC_Init(); // Initialize ADC module with default settings
//LCD module connection;
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_Direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
//end LCD module connection
unsigned char op;
void main() {
porta=0;
portb=0;
portc=0;
TRISB=0X00; //PORTb are out put(LCD)

Electrical and computer engineering Page 48


Building automation system 2016
TRISA=0*FF; //PORTA IS INPUT
TRISC=1;
portd=0; //PORTC is an output
trisd=0;
//Initializing LCD
LCD_Init();
//ADC_Init ();
//set data on display the first time
Lcd_cmd(_LCD_CLEAR);
Lcd_cmd(_LCD_CURSOR_OFF);
Lcd_out(1,1,"counter:");
Lcd_out(2,1,"light:");
intToStr(people, txt);
intToStr(light, txt1);
lcd_out(1,10,txt);
lcd_out(2,7,txt1);
delay_ms(1000);
while (1){
//LCD_inIt();
if(portc.f0==1){
m=1;
}
if(m==1){
people++;
light=1;
portd.f3=1;
//delay_ms(100);
//people=0;

Electrical and computer engineering Page 49


Building automation system 2016
m=0,n=0;
}
if(portc.f1==1){
n=1;
}
if(n==1){
if(people>0){
people--;
light=1;
portd.f3=1;
}
if(people<=0){
people=0;
light=0;
portd.f3=0;
//delay_ms(100);
//people=0;
}
m=0,n=0;
}
intToStr(people, txt);
intToStr(light, txt1);
lcd_out(1,10,txt);
lcd_out(2,7,txt1);
delay_ms(250);
}
}

Electrical and computer engineering Page 50


Building automation system 2016

2. Code for automatic temperature control system


char txt[7];
unsigned int TEMP=0,temprature=0;
//Unsigned char op;
//lcd module connections
sbit LCD_RS at RB2_bit;
sbit LCD_EN at RB3_bit;
sbit LCD_D4 at RB4_bit;
sbit LCD_D5 at RB5_bit;
sbit LCD_D6 at RB6_bit;
sbit LCD_D7 at RB7_bit;
sbit LCD_RS_Direction at TRISB2_bit;
sbit LCD_EN_Direction at TRISB3_bit;
sbit LCD_D4_direction at TRISB4_bit;
sbit LCD_D5_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB6_bit;
sbit LCD_D7_Direction at TRISB7_bit;
//End lcd module connecction
// unsigned char op ,txt1 , txt ,FF;
void main() {
porta=0;
portb=0;
portd=0;
portc=0;
TRISB=0; //PORTb are out put(LCD)
TRISA=1;
trisc=0; //PORTA IS INPUT

Electrical and computer engineering Page 51


Building automation system 2016
TRISd=0; //as an out put
//Initializing LCD
LCD_Init();
ADC_Init ();
//set data on display the first time
Lcd_cmd(_LCD_CLEAR);
Lcd_cmd(_LCD_CURSOR_OFF);
Lcd_out(1,1,"TEMPRATURE =");
Lcd_out(2,5,"c");
intToStr(temprature, txt);
//intToStr(c,txt1);
Lcd_out(2,1,txt);
//Lcd_out(2,7,txt1);
delay_ms(1000);
while (1){
TEMP=adc_read(0);
if(TEMP >56){
portc.f0=1;
}
else{
portc.f0=0;
}
temprature=((TEMP+3.4)/2.2)+1;
Lcd_cmd(_LCD_CLEAR);
Lcd_cmd(_LCD_CURSOR_OFF);
Lcd_out(1,1,"TEMPRATURE =");
Lcd_out(2,7,"C");
intToStr(temprature, txt);

Electrical and computer engineering Page 52


Building automation system 2016
Lcd_out(2,1,txt);
delay_ms(1000);
//else{
}
}

3. Code for automatic door security system


//use rse232(baud=9600,xmit=PIN_vD0,rcv=PIN_D1)//enable serial
communication
//use fast_io(D)//use portD as input output
//int d0,d1 nudig//global variables
//int D;
unsigned short kp, cnt, w1;
char txt[10],pwd[4];
int i=0,j;
// Keypad module connections
char keypadPort at PORTb;
// Lcd pinout settings
sbit LCD_RS at RC2_bit;
sbit LCD_EN at RC3_bit;
sbit LCD_D4 at RC4_bit;
sbit LCD_D5 at RC5_bit;
sbit LCD_D6 at RC6_bit;
sbit LCD_D7 at RC7_bit;
// Pin direction
sbit LCD_RS_Direction at TRISC2_bit;
sbit LCD_EN_Direction at TRISC3_bit;
sbit LCD_D7_Direction at TRISC7_bit;
sbit LCD_D6_Direction at TRISC6_bit;

Electrical and computer engineering Page 53


Building automation system 2016
sbit LCD_D5_Direction at TRISC5_bit;
sbit LCD_D4_Direction at TRISC4_bit;
void code_enter(){
kp = 0; // Reset key code variable
// Wait for key to be pressed and released
do
// kp = Keypad_Key_Press(); // Store key code in kp variable
kp = Keypad_Key_Click(); // Store key code in kp variable
while(!kp);
// Prepare value for output, transform key to it's ASCII value
switch (kp) {
//case 10: kp = 42; break; // '*' // Uncomment this block for keypad4x3
//case 11: kp = 48; break; // '0'
//case 12: kp = 35; break; // '#'
//default: kp += 48;

case 1: kp = 49; break; // 1 // Uncomment this block for keypad4x4


case 2: kp = 50; break; // 2
case 3: kp = 51; break; // 3
//case 4: kp = 65; break; // A
case 5: kp = 52; break; // 4
case 6: kp = 53; break; // 5
case 7: kp = 54; break; // 6
//case 8: kp = 66; break; // B
case 9: kp = 55; break; // 7
case 10: kp = 56; break; // 8
case 11: kp = 57; break; // 9
//case 12: kp = 67; break; // C

Electrical and computer engineering Page 54


Building automation system 2016
case 13: kp = 42; break; // *
case 14: kp = 48; break; // 0
case 15: kp = 35; break; // #
//case 16: kp = 68; break; // D
}
txt[i]=kp;
//lcd_cmd(_lcd_clear);
lcd_out(2,i+1,"*");
i++;

}
void code_read(){
delay_ms(20);
pwd[0]=eeprom_read(0x00);
delay_ms(20);
pwd[1]=eeprom_read(0x01);
delay_ms(20);
pwd[2]=eeprom_read(0x02);
delay_ms(20);
pwd[3]=eeprom_read(0x03);
delay_ms(20);
}
void code_write(){
delay_ms(20);
eeprom_write(0x00,txt[0]);
delay_ms(20);
eeprom_write(0x01,txt[1]);
delay_ms(20);

Electrical and computer engineering Page 55


Building automation system 2016
eeprom_write(0x02,txt[2]);
delay_ms(20);
eeprom_write(0x03,txt[3]);
delay_ms(20);
}
void change_code(){
lcd_cmd(_lcd_clear);
lcd_out(1,1,"set pwd");
i=0;
code_enter();
code_enter();
code_enter();
code_enter();
code_write();
delay_ms(20);
code_read();
delay_ms(20);
lcd_cmd(_lcd_clear);
lcd_out(1,1,"pwd set");
delay_ms(5000);
}
void main(){
keypad_init(); //keypad initialization
lcd_init(); //lcd initialization
portb=0;
portc=0;
portd=0;
trisb=0;

Electrical and computer engineering Page 56


Building automation system 2016
trisc=0;
trisd=0;
cnt=0;
code_read();
lcd_cmd(_lcd_clear);
lcd_cmd(_lcd_cursor_off);
L1: do{
lcd_cmd(_lcd_clear);
lcd_cmd(_lcd_cursor_off);
lcd_out(2,3,"press *");
i=0;
code_enter();
if(txt[0]==42){
lcd_cmd(_lcd_clear);
lcd_out(1,1,"enter code");
i=0;
code_enter();
code_enter();
code_enter();
code_enter();
code_enter();
if(txt[0]=='1'&&txt[1]=='2'&&txt[2]=='3'&&txt[3]=='4'&&txt[4]=='5'){
code_enter();
if(txt[5]==35){
change_code();
}
}
else if(cnt<3&&txt[0]==pwd[0]&&txt[1]==pwd[1]&&txt[2]==

Electrical and computer engineering Page 57


Building automation system 2016
pwd[2]&&txt[3]==pwd[3]&&txt[4]==35){
lcd_cmd(_lcd_clear);
lcd_out(1,4,"door open");
eeprom_read(0x21);
w1=1;
delay_ms(20);
eeprom_write(0x21,w1);
delay_ms(20);
eeprom_read(0x21);
portd=0x0c;
delay_ms(500);
portd=0x18;
delay_ms(500);
portd=0x30;
delay_ms(500);
portd=0x24;
delay_ms(5000);
lcd_cmd(_lcd_clear);
lcd_out(1,4,"door close");
eeprom_read(0x21);
w1=0;
delay_ms(20);
eeprom_write(0x21,w1);
delay_ms(20);
eeprom_read(0x21);
portd=0x24;
delay_ms(500);
portd=0x30;

Electrical and computer engineering Page 58


Building automation system 2016
delay_ms(500);
portd=0x18;
delay_ms(500);
portd=0x0c;
delay_ms(500);
delay_ms(2000);
}
else{
cnt++;
lcd_cmd(_lcd_clear);
lcd_out(1,1,"wrong password");
delay_ms(2000);
}
if(cnt>=3)
goto L1;
}
}while(1);
}

Electrical and computer engineering Page 59

You might also like