automatic full report

62
AUTOMATIC ROOM LIGHT CONTROL WITH VISITOR COUNTER MINI PROJECT REPORT Submitted by: ADHIL MUBARAK AFEEFA KUNH MOHAMMED BIPIN.M NASWIHA.T to the University Of Calicut in partial fulfillment of the requirement for the award of the degree of BACHELOR OF TECHNOLOGY in APPLIED ELECTRONICS AND INSTRUMENTATION ENGINEERING DEPARTMENT OF APPLIED ELECTRONICS AND INSTRUMENTATION ENGINEERING MES COLLEGE OF ENGINEERING, KUTTIPPURAM (ISO 9001:2000 certified & NBA accredited institution)

Upload: afeefa-mohammed

Post on 20-Apr-2015

899 views

Category:

Documents


0 download

DESCRIPTION

Automatic room light controller with visitor counter

TRANSCRIPT

Page 1: Automatic Full Report

AUTOMATIC ROOM LIGHT CONTROL WITHVISITOR COUNTER

MINI PROJECT REPORT

Submitted by:

ADHIL MUBARAK

AFEEFA KUNH MOHAMMED

BIPIN.M

NASWIHA.T

to

the University Of Calicut

in partial fulfillment of the requirement for the award of the degree

of

BACHELOR OF TECHNOLOGY

in

APPLIED ELECTRONICS AND INSTRUMENTATION

ENGINEERING

DEPARTMENT OF

APPLIED ELECTRONICS AND INSTRUMENTATION

ENGINEERING

MES COLLEGE OF ENGINEERING, KUTTIPPURAM

(ISO 9001:2000 certified & NBA accredited institution)

MAY 2012

Page 2: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

ACKNOWLEDGEMENT

First of all we thank the almighty Lord for giving all the confidence and ability to

achieve this dream.

We would also like to take this opportunity to thank a few who were closely

involved in the completion of our project. We are indebted to all sources that helped us in

working out this project at each step of its progress. We sincerely thank Mr. K.P

Mohandas, head of the department, applied electronics and instrumentation, for the

valuable help provided to us. We are also grateful to our project coordinators Mr.

Vijilesh, Mr. Yasar Arafat, Mrs. Shruty and Mr. Hamza of applied electronics and

instrumentation for their valuable suggestions and proper guidance for completion of our

project.

We also express our gratitude to all our teachers and friends for motivating us with

constant encouragement and cooperation.

Dept. of Applied Electronics & Instrumentation 2 MES College of Engineering

Page 3: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

ABSTRACT

In this competitive world and busy schedule human cannot spare time to perform

his daily activities manually. The most common thing that he forgets to do is switching

OFF the lights wherever they are not required. This project is a standalone automatic room

light controller with visitor counter. The main aim of the project is to control the lighting

in a room depending upon lighting that is present in the room. Use of embedded

technology makes this closed loop feedback control system efficient and reliable

Dept. of Applied Electronics & Instrumentation 3 MES College of Engineering

Page 4: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

TABLE OF CONTENT

1. INTRODUCTION........................................................................................................5

1.1 Project Definition...............................................................................................5

1.2 Project Overview................................................................................................5

2. BLOCK DIAGRAM AND ITS DESCRIPTION......................................................6

2.1 Basic Block Diagram..........................................................................................6

2.2 Block Diagram Description................................................................................7

3. CIRCUIT DIAGRAM AND ITS DESCRIPTION...................................................9

3.1 Circuit Diagram:..................................................................................................9

3.2 Circuit Diagram Explanation:...........................................................................10

4. HARDWARE DESIGN & DESCRIPTIONS..........................................................11

4.1 Hardware Design:..............................................................................................11

4.2 Procedure Followed While Designing :............................................................11

4.3 List of Components :.........................................................................................12

4.4 Description of Components...............................................................................12

5. SOFTWARE DESIGN..............................................................................................20

6. TESTING AND RESULTS.......................................................................................40

7. FUTURE EXPANSION.............................................................................................41

8. APPLICATION, ADVANTAGES & DISADVANTAGES....................................42

9. BIBILOGRAPHY......................................................................................................43

Dept. of Applied Electronics & Instrumentation 4 MES College of Engineering

Page 5: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

1. INTRODUCTION

1.1 Project Definition

Project title is “AUTOMATIC ROOM LIGHT CONTROLLER WITH VISITOR

COUNTER “.

The objective of this project is to make a controller based model to count number

of persons visiting particular room and accordingly light up the room. Here we can use

sensor and can know present number of persons.

In today’s world, there is a continuous need for automatic appliances with the

increase in standard of living; there is a sense of urgency for developing circuits that

would ease the complexity of life.

Also if at all one wants to know the number of people present in room so as not to

have congestion. This circuit proves to be helpful.

1.2 Project Overview

This Project “Automatic Room Light Controller with Visitor Counter using

Microcontroller is a reliable circuit that takes over the task of controlling the room lights

as well us counting number of persons/ visitors in the room very accurately. When

somebody enters into the room then the counter is incremented by one and the light in the

room will be switched ON and when any one leaves the room then the counter is

decremented by one. The light will be only switched OFF until all the persons in the room

go out. The total number of persons inside the room is also displayed on the seven

segment displays.

The microcontroller does the above job. It receives the signals from the sensors,

and this signal is operated under the control of software which is stored in ROM.

Microcontroller AT89C51 continuously monitor the Infrared Receivers, When any object

pass through the IR Receiver's then the IR Rays falling on the receiver are obstructed , this

obstruction is sensed by the Microcontroller

Dept. of Applied Electronics & Instrumentation 5 MES College of Engineering

Page 6: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

2. BLOCK DIAGRAM AND ITS DESCRIPTION

2.1 Basic Block Diagram

Enter Exit

Fig. 2.1 : Basic Block Diagram

Dept. of Applied Electronics & Instrumentation 6 MES College of Engineering

Enter Sensor

Exit Sensor

Power Supply

Signal Conditioning

AT89C51

Light

Relay DriverSignal Conditioning

LCD display

Page 7: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

2.2 Block Diagram Description

The basic block diagram of the bidirectional visitor counter with automatic light

controller is shown in the above figure. Mainly this block diagram consists of the

following essential blocks.

1. Power Supply

2. Entry and Exit sensor circuit

3. AT 89C51 micro-controller

4. Relay driver circuit

5. 7-segment display and LCD display

1. Power Supply :

Here we used +12V and +5V dc power supply. The main function of this

block is to provide the required amount of voltage to essential circuits. +12 voltage

is given. +12V is given to relay driver. To get the +5V dc power supply we have

used here IC 7805, which provides the +5V dc regulated power supply.

2. Enter and Exit Circuits :

This is one of the main parts of our project. The main intention of this

block is to sense the person. For sensing the person and light we are using the light

dependent register (LDR). By using this sensor and its related circuit diagram we

can count the persons.

3. 89C51 Microcontroller :

The AT89C51 is a low-power; high-performance CMOS 8-bit

microcomputer with4K bytes of Flash programmable and erasable read only

memory (PEROM). The device is manufactured using Atmel’s high-density

nonvolatile memory technology and is compatible with the industry-standard

MCS-51 instruction set and pin out. The on-chip flash allows the program memory

to be reprogrammed in-system or by a conventional nonvolatile memory

programmer. By combining a versatile 8-bit CPU with Flash on a monolithic chip,

the Atmel AT89C51 is a powerful microcomputer which provides a highly-flexible

and cost-effective solution to many embedded control applications.

Dept. of Applied Electronics & Instrumentation 7 MES College of Engineering

Page 8: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

4. Relay Driver Circuit :

This block has the potential to drive the various controlled devices. In this

block mainly we are using the transistor and the relays. One relay driver circuit we

are using to control the light.

5. 7-Segment display & LCD display :

This block is mainly used to display the number of persons inside the room.

Here we use two 7-segment display and is connected to the AT89C51

microcontroller which programmed to show a count till 25. The LCD display is

also used for the same purpose but also displays the project topic.

Dept. of Applied Electronics & Instrumentation 8 MES College of Engineering

Page 9: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

3. CIRCUIT DIAGRAM AND ITS DESCRIPTION

3.1 Circuit Diagram:

XTAL218

XTAL119

ALE30

EA31

PSEN29

RST9

P0.0/AD039

P0.1/AD138

P0.2/AD237

P0.3/AD336

P0.4/AD435

P0.5/AD534

P0.6/AD633

P0.7/AD732

P1.01

P1.12

P1.23

P1.34

P1.45

P1.56

P1.67

P1.78

P3.0/RXD10

P3.1/TXD11

P3.2/INT012

P3.3/INT113

P3.4/T014

P3.7/RD17

P3.6/WR16

P3.5/T115

P2.7/A1528

P2.0/A821

P2.1/A922

P2.2/A1023

P2.3/A1124

P2.4/A1225

P2.5/A1326

P2.6/A1427

U1

AT89C51

23456789 1

RP1RESPACK-8220E

D7

14D6

13D5

12D4

11D3

10D2

9D1

8D0

7E

6RW

5RS

4

VSS

1VDD

2VEE

3

LCD1LM016L

X111.0592MHz

C1

33pf

C2

33pf

R210k

C310mf

Q1NPN

R14.7K

IR1

D1LED

R347E

TR1

TRAN-2P2S

D2

D3

D4

D5

C41000mF

VI1

VO3

GND

2

U27805

C51mF D6

LED

R41k

PORT2

Q2NPN

R54.7K

IR2

D7LED

R647E

IR1IR2

Relay

1B1

1C16

2B2

2C15

3B3

3C14

4B4

4C13

5B5

5C12

6B6

6C11

7B7

7C10

COM9

U3

ULN2003A

RL112V

Relay

Phase Neutral

Bulb

Fig 3.1: circuit diagram

Dept. of Applied Electronics & Instrumentation 9 MES College of Engineering

Page 10: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

3.2 Circuit Diagram Explanation:

The 230V ac supply is stepped down using a 12-0-12 step down transformer to get

the required voltage for the circuit. The output of transformer is given to a combination of

diodes that act as diode rectifiers. The circuit consists of an LED that indicates whether the

power supply is ON or OFF. The supply from the transformer is regulated to 5V using a

regulator IC7805 which is then given to the microcontroller. Microcontroller AT89C51 is

the main part of the circuit which is programmed to sense and count up to 25 persons. The

LCD display and 7-segment displays are connected to the microcontroller and are used to

display the number of count. The microcontroller is also connected to a relay which

requires 12V but the controller gives out 5V therefore it is connected to relay with the help

of an IC ULN2003APG which provides the relay with 12V which is then connected to

bulb. A reset button is connected so as to start the program from the beginning.

The sensing part mainly consists of an infrared transmitting LED for transmitting

the signals and a phototransistor is used to sense the transmitted signals.

Working

When somebody enters into the room then the counter is incremented by one and

the light in the room will be switched ON and when any one leaves the room then the

counter is decremented by one. The light will be only switched OFF until all the persons in

the room go out. The total number of persons inside the room is also displayed on the

seven segment displays.

The microcontroller does the above job. It receives the signals from the sensors,

and this signal is operated under the control of software which is stored in ROM.

Microcontroller AT89C51 continuously monitor the Infrared Receivers, When any object

pass through the IR Receiver's then the IR Rays falling on the receiver are obstructed , this

obstruction is sensed by the Microcontroller.

Dept. of Applied Electronics & Instrumentation 10 MES College of Engineering

Page 11: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

4. HARDWARE DESIGN & DESCRIPTIONS

4.1 Hardware Design:

Fig. 4.1: Snap of the entire circuit

4.2 Procedure Followed While Designing :

First we tried the circuit on bread board and then we programmed the

microcontroller using KEIL software using hex file.

The desired output was not obtained on the side of microcontroller section. Then

we did the connections on PCB and then soldering process was done. After completion of

the soldering process we tested the circuit.

Dept. of Applied Electronics & Instrumentation 11 MES College of Engineering

Microcontroller AT89C51

7-Segment Display

Relay

Infrared LEDS

Photo transistors

LCD Display

Page 12: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

4.3 List of Components :

Following is the list of components that are necessary to build the assembly of the

Digital Speedometer Cum Odometer:

Microcontroller – AT89C51

IC – 7805

Infrared LEDs

Phototransistor

Transformer – 12-0-12, 1A

Preset – RV1

Disc capacitor – 10mF,1000mF,1mF

Reset button switch

Rectifier diode – IN4001

Transistor – BC 547

7-Segment Display and LCD display - JDH 162A

IC - ULN2003APG

4.4 Description of Components

4.4.1 Microcontroller AT89C51 :

Fig. 4.2: AT89C51

Dept. of Applied Electronics & Instrumentation 12 MES College of Engineering

Page 13: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

The AT89C51 is a low-power, high-performance CMOS 8-bit microcomputer with

4KBytes of Flash programmable and erasable read only memory (PEROM). The device is

manufactured using Atmel’s high-density nonvolatile memory technology and is

compatible with the industry-standard MCS-51 instruction set and pin out. The on-chip

flash allows the program memory to be reprogrammed in-system or by a conventional

nonvolatile memory programmer. By combining a versatile 8-bit CPU with flash on a

monolithic chip, the Atmel AT89C51 is a powerful microcomputer which provides a

highly-flexible and cost-effective solution to many embedded control applications.

The AT89C51 provides the following standard features: 8K bytes of Flash, 256

bytes of RAM, 32 I/O lines, Watchdog timer, two data pointers, three 16-bit

timer/counters, a six-vector two-level interrupt architecture, a full duplex serial port, on-

chip oscillator, and clock circuitry. In addition, the AT89C51 is designed with static logic

for operation from 0Hz to 24Mz and supports two software selectable power saving

modes. The Idle Mode stops the CPU while allowing the RAM, timer/counters, serial port,

and interrupt system to continue functioning. The Power-down mode saves the RAM con-

tents but freezes the oscillator, disabling all other chip functions until the next interrupt or

hardware reset.

FEATURES:-

Compatible with MCS-51™ Products

4K Bytes of In-System Reprogrammable Flash Memory

Endurance: 1,000 Write/Erase Cycles

Fully Static Operation: 0 Hz to 24 MHz

Three-level Program Memory Lock

128 x 8-bit Internal RAM

32 Programmable I/O Lines

Two 16-bit Timer/Counters

Six Interrupt Sources

Programmable Serial Channel

Low-power Idle and Power-down Modes

Dept. of Applied Electronics & Instrumentation 13 MES College of Engineering

Page 14: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

4.4.2 Phototransistor :

Fig. 4.3: Phototransistor

Like diodes, all transistors are light-sensitive. Phototransistors are designed

specifically to take advantage of this fact. The most-common variant is an NPN bipolar

transistor with an exposed base region. Here, light striking the base replaces what would

ordinarily be voltage applied to the base -- so, a phototransistor amplifies variations in the

light striking it. Note that phototransistors may or may not have a base lead (if they do, the

base lead allows you to bias the phototransistor's light response).

4.4.3 Infrared transmitting Led:

Fig. 4.4: Infrared LED

An IR LED, also known as IR transmitter, is a special purpose LED that transmits

infrared rays in the range of 760 nm wavelength. Such LEDs are usually made of gallium

arsenide or aluminum gallium arsenide. They, along with IR receivers, are commonly used

as sensors.

The appearance is same as a common LED. Since the human eye cannot see the

infrared radiations, it is not possible for a person to identify whether the IR LED is

working or not, unlike a common LED. To overcome this problem, the camera on a

cellphone can be used. The camera can show us the IR rays being emanated from the IR

LED in a circuit 5mm LED & has a blue transparent lens Specifications:- Forward Current

Dept. of Applied Electronics & Instrumentation 14 MES College of Engineering

Page 15: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

(If): 50mA max - Peak forward current (Ip): 1.2A- Forward Voltage (VF): 1.2V @ 20mA

- Reverse Voltage (VR): 5V max- Power Dissipation (P.d): 100mW max - Viewing Angle:

30°- Peak Spectral Wavelength(IR): 940nm @ 20mA * Spectral Bandwidth (DI):

50nm@20mA- Material: GaAs

4.4.4 LCD display :

Fig. 4.5: LCD display

LCDs are more energy efficient and offer safer disposal than CRTs. Its low

electrical power consumption enables it to be used in battery-powered electronic

equipment. It is an electronically modulated optical device made up of any number of

segments filled with liquid crystals and arrayed in front of a light source (backlight) or

reflector to produce images in color or monochrome. The most flexible ones use an array

of small pixels

4.4.5 Transformer (12-0-12):

Fig. 4.6: Transformer

Dept. of Applied Electronics & Instrumentation 15 MES College of Engineering

Page 16: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

A transformer is a device that transfers electrical energy from one circuit to another

through inductively coupled conductors—the transformer's coils. A varying current in the

first or primary winding creates a varying magnetic flux in the transformer's core and thus

a varying magnetic field through the secondary winding. This varying magnetic field

induces a varying electromotive force (EMF), or "voltage", in the secondary winding. This

effect is called inductive coupling.

If a load is connected to the secondary, current will flow in the secondary winding,

and electrical energy will be transferred from the primary circuit through the transformer

to the load. In an ideal transformer, the induced voltage in the secondary winding (Vs) is in

proportion to the primary voltage (Vp) and is given by the ratio of the number of turns in

the secondary (Ns) to the number of turns in the primary (Np) as follows:

Vs/Vp=Ns/Np

By appropriate selection of the ratio of turns, a transformer thus enables an

alternating current (AC) voltage to be "stepped up" by making Ns greater than Np, or

"stepped down" by making Ns less than Np.

4.4.6 IC - ULN2003APG :

Fig. 4.7: IC-ULN2003APG

The ULN2003APG/AFWG Series are high−voltage, high−current Darlington

drivers comprised of seven NPN Darlington pairs. All units feature integral clamp diodes

for switching inductive loads. Applications include relay, hammer, lamp and display

(LED) drivers. The suffix (G) appended to the part number represents a Lead (Pb)-Free

product.

Dept. of Applied Electronics & Instrumentation 16 MES College of Engineering

Page 17: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

Features:

Output current (single output): 500 mA max

High sustaining voltage output: 50 V min

Output clamp diodes

Inputs compatible with various types of logic

Package Type-APG: DIP-16pin

Package Type-AFWG: SOL-16pin

4.4.7 LTS 542 (7-Segment Display) :

The LTS 542 is a 0.52 inch digit height single digit seven-segment display. This

device utilizes Hi-eff. Red LED chips, which are made from GaAsP on GaP substrate, and

has a red face and red segment.

Fig. 4.8: Segment

Features:

Common Anode

0.52 Inch Digit Height

Continuous Uniform Segments

Low power Requirement

Excellent Characters Appearance

High Brightness & High Contrast

Wide Viewing Angle

Dept. of Applied Electronics & Instrumentation 17 MES College of Engineering

Page 18: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

4.4.8 LM7805 (voltage regulator :

Fig. 4.9: Voltage Regulator

The KA78XX/KA78XXA series of three-terminal positive regulator are

available in the TO-220/D-PAK package and with several fixed output voltages, making

them useful in a wide range of applications. Each type employs internal current limiting,

thermal shut down and safe operating area protection, making it essentially indestructible.

If adequate heat sinking is provided, they can deliver over 1A output current. Although

designed primarily as fixed voltage regulators, these devices can be used with external

components to obtain adjustable voltages and currents.

Features:

Output Current up to 1A

Output Voltages of 5, 6, 8, 9, 10, 12, 15, 18, 24V

Thermal Overload Protection

Short Circuit Protection

Output Transistor Safe Operating Area Protection

4.4.9 Relay circuit

Fig. 4.10: Relay

Dept. of Applied Electronics & Instrumentation 18 MES College of Engineering

Page 19: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

A single pole dabble throw (SPDT) relay is connected to port RB1 of the

microcontroller through a driver transistor. The relay requires 12 volts at a current of

around 100ma, which cannot provide by the microcontroller. So the driver transistor is

added. The relay is used to operate the external solenoid forming part of a locking device

or for operating any other electrical devices. Normally the relay remains off. As soon as

pin of the microcontroller goes high, the relay operates. When the relay operates and

releases. Diode D2 is the standard diode on a mechanical relay to prevent back EMF from

damaging Q3 when the relay releases. LED L2 indicates relay on.

Dept. of Applied Electronics & Instrumentation 19 MES College of Engineering

Page 20: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

5. SOFTWARE DESIGN

5.1 FLOW CHART

Fig 5.1: Flow Chart

Dept. of Applied Electronics & Instrumentation 20 MES College of Engineering

Start

Infrared Signal Transmission

Turn ON Relay

Interrupted from sensor1

Interrupted from sensor2

Counter Incremented

Turn OFF Relay

Counter Decremented

Counter Set to 0

Relay Turn OFF

Turn OFF Light

Page 21: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

Flow Chart Explanation

1. If the sensor 1 is interrupted first then the microcontroller will look for the

sensor2.And if it is interrupted then the microcontroller will increment the

count and switch on the relay, if it is first time interrupted.

2. If the sensor 2 is interrupted first then the microcontroller will look for the

sensor 1. And if it is interrupted then the microcontroller will decrement the

count.

3. When the last person leaves the room then counter goes to 0 and that time the

relay will turn off. And light will be turn off.

Dept. of Applied Electronics & Instrumentation 21 MES College of Engineering

Page 22: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

5.2 PROGRAM

#include<REGX51.h>

#include<stdio.h>

#include<string.h>

/*----------------PIN Declarations----------------------------------*/

#define LCD_BUS P0

sbit LCD_RS = P1^0; //LCD Register

Select

sbit LCD_E = P1^1; //LCD Enable

sbit Relay = P1^2;

sbit first = P1^4;

sbit second = P1^3;

sbit IR1 = P1^5;

sbit IR2 = P1^6;

/*-----------------Global Variables----------------------------*/

char lu[17];

int i,j,count=0,count1 = 0,flag1 = 1,flag2 =1;

/*-------------Function Declarations----------------------*/

void lcdinit(); //to initialize lcd

void data2lcd(unsigned char ); //commands to lcd

void disp_msg(); //to display

message

int disp_num(unsigned char,unsigned char); //to display number

void delay(); //to

generate 5ms

void delay_s(); //to generate 1s

Dept. of Applied Electronics & Instrumentation 22 MES College of Engineering

Page 23: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

void disp_clr(); //to clear display

void lcd_pos(unsigned char); //to select position

void zero1();

void zero2();

void one1();

void one2();

void two1();

void two2();

void three1();

void four1();

void five1();

void six1();

void seven1();

void eight1();

void nine1();

void check();

/*--------------Main-----------------------------------------*/

void main()

{

Relay = 1;

TMOD=0X01;

delay();

Relay = 1;

lcdinit();

disp_clr();

lcd_pos(0x80);

strcpy(lu," Automatic Room ");

disp_msg();

lcd_pos(0xc0);

strcpy(lu,"Light Controller");

disp_msg();

for(i=0;i<12;i++)

Dept. of Applied Electronics & Instrumentation 23 MES College of Engineering

Page 24: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

delay_s();

disp_clr();

delay();

lcd_pos(0x80);

strcpy(lu,"PersonCount:");

disp_msg();

while(1)

{

// if(IR1 == 1)

// {

// for(j=0;j<10;j++)

// {

//

// if((IR2 == 1)&&(flag1==1))

// {

// flag1 = 0;

// if(count >= 25)

// {

// count = 25;

// count1 = count;

// }

// else

// {

// count++;

Dept. of Applied Electronics & Instrumentation 24 MES College of Engineering

Page 25: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

// count1 = count;

// }

// disp_num(count1,0x8D);

// }

//

// delay();delay();delay();delay();delay();

// }

// flag1=1;

// //delay_s();delay_s();

// }

//

// if(IR2 == 1)

// {

// for(j=0;j<10;j++)

// {

//

//

// if((IR1 == 1)&&(flag2 == 1))

// {

// flag2 = 0;

// if(count <= 0)

// {

// count = 0;

// count1 = count;

Dept. of Applied Electronics & Instrumentation 25 MES College of Engineering

Page 26: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

// }

// else

// {

// count--;

// count1 = count;

// }

// disp_num(count1,0x8D);

// }

// delay();delay();delay();delay();delay();

// }

// flag2 = 1;

// //delay_s();delay_s();

// }

//

// disp_num(count1,0x8D);

if(IR1 == 1)

{

if(count >= 25)

{

count = 25;

count1 = count;

}

else

Dept. of Applied Electronics & Instrumentation 26 MES College of Engineering

Page 27: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

{

count++;

count1 = count;

}

count1 = count;

disp_num(count1,0x8D);

delay_s();delay_s();delay_s();

}

if(IR2 == 1)

{

if(count <= 0)

{

count = 0;

count1 = count;

}

else

{

count--;

count1 = count;

}

count1 = count;

disp_num(count1,0x8D);

delay_s();delay_s();delay_s();

Dept. of Applied Electronics & Instrumentation 27 MES College of Engineering

Page 28: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

}

disp_num(count1,0x8D);

if((count >= 1) && (flag1 == 1))

{

Relay = 0;

flag1 = 0;flag2 = 1;

lcd_pos(0xc0);

strcpy(lu,"Light ON ");

disp_msg();

delay_s();

}

else if((count <= 0) && (flag2 == 1))

{

Relay = 1;

flag1 = 1;flag2 = 0;

lcd_pos(0xc0);

strcpy(lu,"Light OFF ");

disp_msg();

delay_s();

}

if(count == 0)

{

zero1();

zero2();

delay();

}

check();

Dept. of Applied Electronics & Instrumentation 28 MES College of Engineering

Page 29: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

}

}

/*delay for 5ms*/

void delay()

{

TH0=0Xfd; //LOAD VALUE OF TH0

TL0=0XE8; //LOAD VALUE OF TL0

TR0=1; //START TIMER

while(TF0==0); //WAIT TO SET TF0

TR0=0; //CLEAR TR0

TF0=0; //CLEAR TF0

}

void delay_s()

{

unsigned char g;

for(g=0;g<200;g++)

delay();

}

/*-----------------LCD---------------------------*/

void lcdinit()

{

LCD_BUS=0x38;

data2lcd(0);

LCD_BUS=0x0c;

data2lcd(0);

LCD_BUS=0x01;

data2lcd(0);

LCD_BUS=0x80;

data2lcd(0);

}

/*-----DATA OR COMMANDS PROCESSING TO LCD--*/

void data2lcd(unsigned char k)

Dept. of Applied Electronics & Instrumentation 29 MES College of Engineering

Page 30: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

{

LCD_RS=k; //rs

LCD_E=1; //lcd enable

delay();

LCD_E=0;

}

/*-----------clear display----------------*/

void disp_clr()

{

LCD_BUS=0x01;

data2lcd(0);

}

/*to display entire message*/

void disp_msg()

{

unsigned char g;

for(g=0;lu[g]!='\0';g++)

{

LCD_BUS=lu[g];

data2lcd(1);

}

}

///*to display a character*/

//void disp_char(char c)

//{

// LCD_BUS=c;

// data2lcd(1);

//}

/*to select position*/

void lcd_pos(unsigned char pos)

{

LCD_BUS=pos;

data2lcd(0);

}

/*to display multidigit*/

int disp_num(unsigned char t,unsigned char pos)

Dept. of Applied Electronics & Instrumentation 30 MES College of Engineering

Page 31: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

{

unsigned char y,p=0,num[5],nc=0,i;

// while(t>0)

for(i=0;i<3;i++)

{

y=t%10;

num[p]=y;

t=t/10;

p++;

}

pos=pos+p-1;

for(y=0;y<p;y++)

{

LCD_BUS=pos;

data2lcd(0);

num[y]=num[y]&0x0f;

num[y]=num[y]|0x30;//ascii conversion

LCD_BUS=num[y];

data2lcd(1);

pos--;

}

}

void zero2()

{

first = 0;

second = 1;

P2 = 0x81;

delay();delay();delay();

delay();delay();delay();

}

void zero1()

{

first = 1;

second = 0;

Dept. of Applied Electronics & Instrumentation 31 MES College of Engineering

Page 32: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

P2 = 0x81;

delay();delay();delay();

delay();delay();delay();

}

void one2()

{

first = 0;

second = 1;

P2 = 0xB7;

delay();

delay();

}

void one1()

{

first = 1;

second = 0;

P2 = 0xB7;

delay();

delay();

}

void two2()

{

first = 0;

second = 1;

P2 = 0xC2;

delay();

delay();

}

void two1()

{

first = 1;

Dept. of Applied Electronics & Instrumentation 32 MES College of Engineering

Page 33: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

second = 0;

P2 = 0xC2;

delay();

delay();

}

void three1()

{

first = 1;

second = 0;

P2 =0x92;

delay();

delay();

}

void four1()

{

first = 1;

second = 0;

P2 = 0xB4;

delay();

delay();

}

void five1()

{

first = 1;

second = 0;

P2 = 0x98;

delay();

delay();

}

void six1()

{

Dept. of Applied Electronics & Instrumentation 33 MES College of Engineering

Page 34: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

first = 1;

second = 0;

P2 = 0x88;

delay();

delay();

}

void seven1()

{

first = 1;

second = 0;

P2 = 0xB3;

delay();

delay();

}

void eight1()

{

first = 1;

second = 0;

P2 = 0x80;

delay();

delay();

}

void nine1()

{

first = 1;

second = 0;

P2 = 0x90;

delay();

delay();

}

void check()

Dept. of Applied Electronics & Instrumentation 34 MES College of Engineering

Page 35: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

{

if(count == 1)

{

one1();

zero2();

delay();

delay();

}

else if(count == 2)

{

two1();

zero2();

delay();

delay();

}

else if(count == 3)

{

three1();

zero2();

delay();

delay();

}

else if(count == 4)

{

four1();

zero2();

delay();

delay();

}

else if(count == 5)

{

five1();

zero2();

delay();

delay();

}

Dept. of Applied Electronics & Instrumentation 35 MES College of Engineering

Page 36: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

else if(count == 6)

{

six1();

zero2();

delay();

delay();

}

else if(count == 7)

{

seven1();

zero2();

delay();

delay();

}

else if(count == 8)

{

eight1();

zero2();

delay();

delay();

}

else if(count == 9)

{

nine1();

zero2();

delay();

delay();

}

else if(count == 10)

{

zero1();

one2();

delay();

delay();delay();delay();

delay();delay();delay();

Dept. of Applied Electronics & Instrumentation 36 MES College of Engineering

Page 37: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

}

else if(count == 11)

{

one1();

one2();

delay();

delay();

}

else if(count == 12)

{

two1();

one2();

delay();

delay();

}

else if(count == 13)

{

three1();

one2();

delay();

delay();

}

else if(count == 14)

{

four1();

one2();

delay();

delay();

}

else if(count == 15)

{

five1();

one2();

delay();

delay();

}

Dept. of Applied Electronics & Instrumentation 37 MES College of Engineering

Page 38: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

else if(count == 16)

{

six1();

one2();

delay();

delay();

}

else if(count == 17)

{

seven1();

one2();

delay();

delay();

}

else if(count == 18)

{

eight1();

one2();

delay();

delay();

}

else if(count == 19)

{

nine1();

one2();

delay();

delay();

}

else if(count == 20)

{

zero1();

two2();

delay();

delay();

}

else if(count == 21)

Dept. of Applied Electronics & Instrumentation 38 MES College of Engineering

Page 39: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

{

one1();

two2();

delay();

delay();

}

else if(count == 22)

{

two1();

two2();

delay();

delay();

}

else if(count == 23)

{

three1();

two2();

delay();

delay();

}

else if(count == 24)

{

four1();

two2();

delay();

delay();

}

else if(count == 25)

{

five1();

two2();

delay();

delay();

}

}

Dept. of Applied Electronics & Instrumentation 39 MES College of Engineering

Page 40: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

6. TESTING AND RESULTS

We started our project by making power supply. That is easy for us but when we

turn toward the main circuit, there are many problems and issues related to it, which we

faced, like component selection, which components is better than other and its feature and

cost wise. When we finished doing in bread board we couldn’t get the counting section

although sensing was done.

Then we tried out in PCB with some modifications in the program and by changing

some of the components. The connections after soldering were tested and ultimately we

obtained the required result.

Dept. of Applied Electronics & Instrumentation 40 MES College of Engineering

Page 41: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

7. FUTURE EXPANSION

By using this circuit and proper power supply we can implement various

applications

Such as fans, tube lights, etc.

By modifying this circuit and using two relays we can achieve a task of

opening and closing the door.

Dept. of Applied Electronics & Instrumentation 41 MES College of Engineering

Page 42: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

8. APPLICATION, ADVANTAGES & DISADVANTAGES

Application

o For counting persons in a room

o For automatic room light control

Advantages

o Low cost

o Easy to use

Disadvantages

o It is used only when one single person cuts the rays of the sensor hence

it cannot be used when two person cross simultaneously.

o Separate enter and exit doors are required

Dept. of Applied Electronics & Instrumentation 42 MES College of Engineering

Page 43: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

Dept. of Applied Electronics & Instrumentation 43 MES College of Engineering

Page 44: Automatic Full Report

Automatic room light controller with visitor counter Mini Project 2012

9. BIBILOGRAPHY

Reference Books

Programming in ANSI C: E BALAGURUSAMY

The 8051microcontroller and embedded systems: MUHAMMAD ALI

MAZIDI , JANICE GILLISPIE MAZIDI

The 8051 microcontroller: KENNETH J. AYALA

Website

www.8051projects.info

www.datasheets4u.com

www.8051.com

Dept. of Applied Electronics & Instrumentation 44 MES College of Engineering