Sunteți pe pagina 1din 43

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)

MAY 2012

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

MES College of Engineering

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

MES College of Engineering

Automatic room light controller with visitor counter

Mini Project 2012

TABLE OF CONTENT

1.

INTRODUCTION ....................................................................................................... 5 1.1 1.2 Project Definition ............................................................................................... 5 Project Overview ................................................................................................ 5

2.

BLOCK DIAGRAM AND ITS DESCRIPTION ...................................................... 6 2.1 2.2 Basic Block Diagram ......................................................................................... 6 Block Diagram Description ................................................................................ 7

3.

CIRCUIT DIAGRAM AND ITS DESCRIPTION ................................................... 9 3.1 3.2 Circuit Diagram:.................................................................................................. 9 Circuit Diagram Explanation: ........................................................................... 10

4.

HARDWARE DESIGN & DESCRIPTIONS ......................................................... 11 4.1 4.2 4.3 4.4 Hardware Design:.............................................................................................. 11 Procedure Followed While Designing : ............................................................ 11 List of Components : ......................................................................................... 12 Description of Components .............................................................................. 12

5. 6. 7. 8. 9.

SOFTWARE DESIGN .............................................................................................. 20 TESTING AND RESULTS ....................................................................................... 40 FUTURE EXPANSION ............................................................................................ 41 APPLICATION, ADVANTAGES & DISADVANTAGES ................................... 42 BIBILOGRAPHY ...................................................................................................... 43

Dept. of Applied Electronics & Instrumentation

MES College of Engineering

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 todays 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

MES College of Engineering

Automatic room light controller with visitor counter

Mini Project 2012

2. BLOCK DIAGRAM AND ITS DESCRIPTION


2.1 Basic Block Diagram

Enter
Enter Sensor Signal Conditioning

Exit

Exit Sensor

Signal Conditioning

Power Supply

A T 8 9 C 5 1

Relay Driver

Light

LCD display

Fig. 2.1 : Basic Block Diagram

Dept. of Applied Electronics & Instrumentation

MES College of Engineering

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. 2. 3. 4. 5. Power Supply Entry and Exit sensor circuit AT 89C51 micro-controller Relay driver circuit 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 Atmels 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

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

MES College of Engineering

Automatic room light controller with visitor counter

Mini Project 2012

3. CIRCUIT DIAGRAM AND ITS DESCRIPTION


3.1 Circuit Diagram:
D2 TR1
1

U2
7805 3

LCD1
LM016L VO
GND

D3

VI

R4
1k

C4 D4
1000mF

C5
VSS VDD VEE

1mF

D6
LED

RS RW E 4 5 6

TRAN-2P2S

C1 U1
19 33pf XTAL1 P0.0/AD0 P0.1/AD1 18 P0.2/AD2 XTAL2 P0.3/AD3 P0.4/AD4 P0.5/AD5 33pf 9 P0.6/AD6 RST P0.7/AD7 P2.0/A8 39 38 37 36 35 34 33 32 21 22 23 24 25 26 27 28 10 11 12 13 14 15 16 17

X1 C2
11.0592MHz

7 8 9 10 11 12 13 14

D5

1 2 3

D D D D D D D D

0 1 2 3 4 5 6 7

Phase

Neutral

C3
10mf

P2.1/A9

R2
10k

29 30 31

P2.2/A10 PSEN ALE EA P2.3/A11 P2.4/A12 P2.5/A13 P2.6/A14 P2.7/A15

U3
Relay
1 2 3 4 5 6 7 COM 1B 2B 3B 4B 5B 6B 7B ULN2003A 1C 2C 3C 4C 5C 6C 7C 9 16 15 14 13 12 11 10

RL1
12V

1 2 3 4 5 6 7 8

P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 AT89C51

P3.0/RXD P3.1/TXD P3.2/INT0 P3.3/INT1 P3.4/T0 P3.5/T1 P3.6/WR P3.7/RD

Relay

IR1 IR2

Bulb

PORT2

R1
4.7K
9 8 7 6 5 4 3 2 1

R5 R3
47E 4.7K

R6
47E

IR1

IR2

Q1 RP1
RESPACK-8 220E NPN

D1
LED

Q2
NPN

D7
LED

Fig 3.1: circuit diagram


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

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

Automatic room light controller with visitor counter

Mini Project 2012

4. HARDWARE DESIGN & DESCRIPTIONS

4.1 Hardware Design:

Microcontroller AT89C51

Relay

LCD Display

Photo transistors

7-Segment Display Infrared LEDS 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

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

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 Atmels 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, onchip 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 contents 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

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

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

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 conductorsthe 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 highvoltage, highcurrent 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

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

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

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

Automatic room light controller with visitor counter

Mini Project 2012

5. SOFTWARE DESIGN
5.1 FLOW CHART
Start

Infrared Signal Transmission

Turn ON Relay

Interrupted from sensor1

Interrupted from sensor2

Turn OFF Relay

Counter Incremented

Counter Decremented

Counter Set to 0

Relay Turn OFF

Turn OFF Light

Fig 5.1: Flow Chart

Dept. of Applied Electronics & Instrumentation

20

MES College of Engineering

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

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 sbit Select sbit sbit sbit sbit sbit sbit LCD_E Relay first second IR1 IR2 = = = = P1^1; P1^2; P1^4; P1^3; = = P1^5; P1^6; //LCD Enable LCD_RS P0 = P1^0; //LCD Register

/*-----------------Global Variables----------------------------*/ char lu[17]; int i,j,count=0,count1 = 0,flag1 = 1,flag2 =1; /*-------------Function Declarations----------------------*/ void lcdinit(); void data2lcd(unsigned char ); void disp_msg(); message int disp_num(unsigned char,unsigned char); void delay(); generate 5ms void delay_s(); //to generate 1s //to display number //to //to initialize lcd //commands to lcd //to display

Dept. of Applied Electronics & Instrumentation

22

MES College of Engineering

Automatic room light controller with visitor counter


void disp_clr(); void lcd_pos(unsigned char); 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++)

Mini Project 2012


//to clear display //to select position

Dept. of Applied Electronics & Instrumentation

23

MES College of Engineering

Automatic room light controller with visitor counter


delay_s(); disp_clr(); delay(); lcd_pos(0x80); strcpy(lu,"PersonCount:"); disp_msg(); while(1) { // // // // // // // // // // // // // // // // } else { count++; if((IR2 == 1)&&(flag1==1)) { flag1 = 0; if(count >= 25) { count = 25; count1 = count; if(IR1 == 1) { for(j=0;j<10;j++) {

Mini Project 2012

Dept. of Applied Electronics & Instrumentation

24

MES College of Engineering

Automatic room light controller with visitor counter


// // // // // // // // // // // // // // // // // // // // // // // // if((IR1 == 1)&&(flag2 == 1)) { flag2 = 0; if(count <= 0) { count = 0; count1 = count; if(IR2 == 1) { for(j=0;j<10;j++) { } delay();delay();delay();delay();delay(); } flag1=1; //delay_s();delay_s(); } } disp_num(count1,0x8D); count1 = count;

Mini Project 2012

Dept. of Applied Electronics & Instrumentation

25

MES College of Engineering

Automatic room light controller with visitor counter


// // // // // // // // // // // // // // // disp_num(count1,0x8D); } } delay();delay();delay();delay();delay(); } flag2 = 1; //delay_s();delay_s(); } disp_num(count1,0x8D); } else { count--; count1 = count;

Mini Project 2012

if(IR1 == 1) { if(count >= 25) { count = 25; count1 = count; } else

Dept. of Applied Electronics & Instrumentation

26

MES College of Engineering

Automatic room light controller with visitor counter


{ count++; count1 = count; } count1 = count;

Mini Project 2012

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

Automatic room light controller with visitor counter


} disp_num(count1,0x8D); if((count >= 1) && (flag1 == 1)) { Relay = 0; flag1 = 0;flag2 = 1;

Mini Project 2012

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

Automatic room light controller with visitor counter


} }

Mini Project 2012

/*delay for 5ms*/ void delay() { TH0=0Xfd; TL0=0XE8; TR0=1; while(TF0==0); TR0=0; TF0=0; } //LOAD VALUE OF TH0 //LOAD VALUE OF TL0 //START TIMER //WAIT TO SET TF0 //CLEAR TR0 //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

Automatic room light controller with visitor counter


{ LCD_RS=k; LCD_E=1; 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) //{ // // //} /*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) LCD_BUS=c; data2lcd(1);

Mini Project 2012


//rs //lcd enable

Dept. of Applied Electronics & Instrumentation

30

MES College of Engineering

Automatic room light controller with visitor counter


{ 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;

Mini Project 2012

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

Automatic room light controller with visitor counter


P2 = 0x81;

Mini Project 2012

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

Automatic room light controller with visitor counter


second = 0; P2 = 0xC2;

Mini Project 2012

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

Automatic room light controller with visitor counter


first = 1; second = 0; P2 = 0x88;

Mini Project 2012

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

Automatic room light controller with visitor counter


{ 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(); }

Mini Project 2012

Dept. of Applied Electronics & Instrumentation

35

MES College of Engineering

Automatic room light controller with visitor counter


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();

Mini Project 2012

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

Automatic room light controller with visitor counter


} 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(); }

Mini Project 2012

Dept. of Applied Electronics & Instrumentation

37

MES College of Engineering

Automatic room light controller with visitor counter


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)

Mini Project 2012

Dept. of Applied Electronics & Instrumentation

38

MES College of Engineering

Automatic room light controller with visitor counter


{ 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(); } }

Mini Project 2012

Dept. of Applied Electronics & Instrumentation

39

MES College of Engineering

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 couldnt 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

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

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

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

43

MES College of Engineering

S-ar putea să vă placă și