You are on page 1of 19


Objective Introduction Circuit Description List of Components Circuit Diagram Components Description
IC 7805 (Voltage Regulator IC) LM324 Quad Operational Amplifier AT89C51 Microcontroller BC548 Transistor Rectifier Diodes Seven Segment Display Infrared Transmitters & Infrared Receiver Light Emitting Diode Preset Resistors Capacitors Oscillator Circuit Relay Transformer

Program Code Applications & Advantages Future Development

To design a Presence Sensing Light Controller using Microcontroller AT89C51

Wastage of electricity is one of the main problems which we are facing now a day. In our home, school, colleges or industry we see that fan / lights are kept on even if there are nobody in the room or area / passage. This happens due to negligence or because we forgot to turn lights off or we are in hurry. To avoid all such situations we have designed this project called Automatic room light controller with visitor counter 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. Main concept behind this project is known as Visitor counter which measures the number of persons entering in any room like seminar hall, conference room. This function is implemented using a pair of Infrared sensors. LCD display placed outside the room displays this value of person count. This person count will be incremented if somebody enters inside the room and at that time lights are turned on. And in reverse way, person count will be decremented if somebody leaves the room. When number of persons inside the room is zero, lights inside the room are turned off using a relay interface. In this way Relay does the operation of Automatic room light controller. Since this project uses 2 infrared sensors, it can be used as Bidirectional person counter as well.

Circuit Description:

Following are the important modules in this project: 1. IR Transmitter: Reason behind choosing IR LED is, infrared beams are not visible to human eyes and they are not easily triggered by other sources in the environment. Transmitters used are IR LEDs. 2. Microcontroller: This is the CPU (central processing unit) of our project. We have used 89s51 which is a microcontroller of 8051 family. The various functions of microcontroller are like:

I. Bidirectional Visitor counter section It is bidirectional because we have used 2 sensors on a single door. Microcontroller does the function of Reading the digital input from two infrared receivers and calculates the number of persons from them. II. Display - Microcontroller sends the person count to LCD, so that the person operating this project should read the number of persons inside the room. III. Automatic Room Light controller section Microcontroller turns on the Room Light when person count is greater than or equal to one. And turn off lights when count is zero. This is done by Relay. 3. IR Receiver: It is an active low device, which means it gives low output when it receives the Infrared rays. So when the IR rays are interrupted by any person then microcontroller will receive a high pulse from the IR receiver. 4. LCD Display: We have used 162 alphanumeric Liquid Crystal Display (LCD) which means it can display alphabets along with numbers on 2 lines each containing 16 characters. 5. Relay: We have used 12 volt relay. We have used a SPDT relay. SPDT means Single Pole Double Throw relay.

List of Components :
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. IC1 7805 5V Regulator. IC2 LM324 Quad Operational Amplifier. IC3 AT89C51 Microcontroller. T1 BC548 NPN Transistor. D1 to D5 1N4007 Rectifier Diode. DIS1 to DIS3 LTS 542 Common Anode 7 Segment Display. IR TX1, IR TX2 Infrared Transmitters. IR RX1, IR RX2 Infrared Receiver. LED1, LED2 5mm LED. Resistors: R1 470 Ohm. R2, R3 100 Ohm. R4, R5 10 Kilo Ohm. R6 8.2 Kilo Ohm. R7 - 1 Kilo Ohm. R8 680 Ohm. R9 to R32 220 Ohm. VR1, VR2 10 Kilo Ohm Preset. RNW1 10 Kilo Ohm Resistor Network. Capacitors: C1 1000f, 35V Electrolytic. C2 0.1f Ceramic Disk. C3 10f, 16V Electrolytic C4, C5 33pF Ceramic Disk. Miscellaneous: S1 Push to ON tactile Switch Xtal - 12MHz Crystal RL1 12V, 1C/O Relay X1 230V AC Primary to 12V, 500mA Secondary Transformer. 3

Components Description:
IC 7805 (Voltage Regulator IC):

7805 is a voltage regulator integrated circuit. It is a member of 78xx series of fixed linear voltage regulator ICs. The voltage source in a circuit may have fluctuations and would not give the fixed voltage output. The voltage regulator IC maintains the output voltage at a constant value. The xx in 78xx indicates the fixed output voltage it is designed to provide. 7805 provides +5V regulated power supply. Capacitors of suitable values can be connected at input and output pins depending upon the respective voltage levels. Pin Diagram:

Pin Description: Pin No 1 2 3 Function Input voltage (5V-18V) Ground (0V) Regulated output; 5V (4.8V-5.2V) Name Input Ground Output

LM324 Quad Operational Amplifier:

These devices consist of four independent high-gain frequency-compensated operational amplifiers that are designed specifically to operate from a single supply over a wide range of voltages. Applications include transducer amplifiers, dc amplification blocks, and all the conventional operational-amplifier circuits that now can be more easily implemented in single-supply-voltage systems. For example, the LM324 can be operated directly from the standard 5-V supply that is used in digital systems and provides the required interface electronics, without requiring additional 15-V supplies.

Pin Description:
V+ GND = Supply Voltage = GND (0V) connection for supply voltage

Input(s) = Input to Op-Amp Output = Output of Op-Amp

Electrical Characteristics:
Operating Voltage: Maximum Supply Current: = 3.0V to 32V = 1.2mA @ 5V Operating Voltage = 3mA @ 30V Operating Voltage High Level Output Voltage: = 3.5V @ 5V Operating Voltage = 28V @ 30V Operating Voltage Maximum Output Current = 40mA @ 5V Operating Voltage

Operating Temperature = 0C to 70C

AT89C51 Microcontroller:

AT89C51 is an 8-bit microcontroller and belongs to Atmel's 8051 family. ATMEL 89C51 has 4KB of Flash programmable and erasable read only memory (PEROM) and 128 bytes of RAM. It can be erased and program to a maximum of 1000 times.

In 40 pin AT89C51, there are four ports designated as P1, P2, P3 and P0. All these ports are 8-bit bi-directional ports, i.e., they can be used as both input and output ports. Except P0 which needs external pull-ups, rest of the ports have internal pull-ups. When 1s are written to these port pins, they are pulled high by the internal pull-ups and can be used as inputs. These ports are also bit addressable and so their bits can also be accessed individually. Pin Description: Pin No 1 2 3 4 5 6 7 8 9 Function Name P1.0 P1.1 P1.2 P1.3 P1.4 P1.5 P1.6 P1.7 Reset

8 bit input/output port (P1) pins

Reset pin; Active high

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40

Input (receiver) for communication Output (transmitter) for communication External interrupt 1 External interrupt 2 Timer1 external input Timer2 external input Write to external data memory Read from external data memory

serial serial

RxD TxD Int0 Int1 T0 T1 Write Read

P3.0 P3.1 P3.2 8 bit input/output port P3.3 (P3) pins P3.4 P3.5 P3.6 P3.7

Crystal 2 Crystal 1 Ground (0V) Ground P2.0/ A8 P2.1/ A9 P2.2/ A10 8 bit input/output port (P2) pins/High-order address bits when interfacing with P .3/ A 2 11 external memory P2.4/ A12 P2.5/ A13 P2.6/ A14 P2.7/ A15 Quartz crystal oscillator (up to 24 MHz) Program store enable; Read from external program memory Address Latch Enable Program pulse input during Flash programming External Access Enable; Vcc for internal program executions Programming enable voltage; 12V (during Flash programming) PSEN ALE Prog EA Vpp P0.7/ AD7 P0.6/ AD6 P0.5/ AD5 P0.4/ AD4 P0.3/ AD3 P0.2/ AD2 P0.1/ AD1 P0.0/ AD0 Vcc

8 bit input/output port (P0) pins Low-order address bits when interfacing with external memory

Supply voltage; 5V (up to 6.6V)

BC548 Transistor:

BC548 is general purpose silicon, NPN, bipolar junction transistor. It is used for amplification and switching purposes. The current gain may vary between 110 and 800. The maximum DC current gain is 800. Its equivalent transistors are 2N3904 and 2SC1815. These equivalent transistors however have different lead assignments. The variants of BC548 are 548A, 548B and 548C which vary in range of current gain and other characteristics. The transistor terminals require a fixed DC voltage to operate in the desired region of its characteristic curves. This is known as the biasing. For amplification applications, the transistor is biased such that it is partly on for all input conditions. The input signal at base is amplified and taken at the emitter. BC548 is used in common emitter configuration for amplifiers. The voltage divider is the commonly used biasing mode. For switching applications, transistor is biased so that it remains fully on if there is a signal at its base. In the absence of base signal, it gets completely off. Pin Diagram :

Rectifier Diodes:
Introduction: In electronics a diode is a two-terminal electronic component that restricts current flow chiefly to one direction. The term usually refers to a semiconductor diode, the most common type today, which is a crystal of semiconductor connected to two electrical terminals, a P-N junction. A vacuum tube diode, now little used, is a vacuum tube with two electrodes; a plate and a cathode. The most common function of a diode is to allow an electric current in one direction (called the forward direction) while blocking current in the opposite direction (the reverse direction). Thus, the diode can be thought of as an electronic version of a check valve. This unidirectional behavior is called rectification, and is used to convert alternating current to direct current, and remove modulation from radio signals in radio receivers. Electronic Symbol:

Semiconductor diodes:

Most diodes today are based on semiconductor p-n junctions. In a p-n diode, conventional current is from the ptype side (the anode) to the n-type side (the cathode), but not in the opposite direction. Another type of semiconductor diode, the Schottky diode, is formed from the contact between a metal and a semiconductor rather than by a p-n junction. Ideal Diode as a Switch: An ideal diode is like a light switch in your home. When the switch is closed, the circuit is completed; and the light turns on. When the switch is open, there is no current and the light is off.

Diode Specifications: The very minimal diode specifications are: (a) Maximum reverse voltage (b) Rated forward current (c) Maximum forward voltage drop (d) Maximum leakage current (e) Package style (f) Maximum reverse recovery time I-V CHARACTERSTICS OF DIODE: Forward Voltage Drop, Vf: Notice that the diode conducts a small current in the forward direction up to a threshold voltage, 0.3 for germanium and 0.7 for silicon; after that it conducts as we might expect. The forward voltage drop, Vf, is specified at a forward current. Leakage Current: In the reverse direction there is a small leakage current up until the reverse breakdown voltage is reached. This leakage is undesirable, obviously the lower the better, and is specified at a voltage less the than breakdown; diodes are intended to operate below their breakdown voltage. Current Rating: The current rating of a diode is determined primarily by the size of the diode chip, and both the material and configuration of the package, Average Current is used, not RMS current.

Applications: Radio Demodulation: The first use for the diode was the demodulation of amplitude modulated (AM) radio broadcasts. Power Conversion: Rectifiers are constructed from diodes, where they are used to convert alternating current (AC) electricity into direct current (DC). Over-voltage Protection: Diodes are frequently used to conduct damaging high voltages away from sensitive electronic devices. They are usually reverse-biased (non-conducting) under normal circumstances. When the voltage rises above the normal range, the diodes become forward-biased (conducting). Logic Gates: Diodes can be combined with other components to construct AND and OR logic gates. This is referred to as diode logic. Temperature Measurements: A diode can be used as a temperature measuring device, since the forward voltage drop across the diode depends on temperature, as in a Silicon band gap temperature sensor. Current Steering: Diodes will prevent currents in unintended directions. To supply power to an electrical circuit during a power failure, the circuit can draw current from a battery. An Uninterruptible power supply may use diodes in this way to ensure that current is only drawn from the battery when necessary.

Seven Segment Display:

A seven segment display is the most basic electronic display device that can display digits from 0-9. They find wide application in devices that display numeric information like digital clocks, radio, microwave ovens, electronic meters etc.

Pin Diagram:

The most common configuration has an array of eight LEDs arranged in a special pattern to display these digits. They are laid out as a squared-off figure 8. Every LED is assigned a name from 'a' to 'h' and is identified by its name. Seven LEDs 'a' to 'g' are used to display the numerals while eighth LED 'h' is used to display the dot/decimal. A seven segment is generally available in ten pin package. While eight pins correspond to the eight LEDs, the remaining two pins (at middle) are common and internally shorted. These segments come in two configurations, namely, Common cathode (CC) and Common anode (CA).In CC configuration, the negative terminals of all LEDs are connected to the common pins. The common is connected to ground and a particular LED glows when its corresponding pin is given high. In CA arrangement, the common pin is given a high logic and the LED pins are given low to display a number.

Infrared Transmitters & Infrared Receiver:

Infrared (IR) transmitters and receivers are present in many different devices, though they are most commonly found in consumer electronics. The way this technology works is that one component flashes an infrared light in a particular pattern, which another component can pick up and translate into an instruction. These transmitters and receivers are found in remote controls and all different types of devices, such as televisions and DVD players. Peripheral devices that include this technology can also allow a computer to control various other consumer electronics. Since infrared remotes are limited to line of sight operation, some products can be used to extend the signals over a hardwired line or radio frequency (RF) transmissions.

Most common consumer electronic remote controls use infrared light. They typically generate infrared using light emitting diodes (LEDs), and the main component of a receiver unit is usually a photodiode. A remote control flashes a pattern of invisible light, which is picked up and then turned into an instruction by the receiver module. The parts necessary to construct transmitter and receiver are typically inexpensive, but these systems are limited to line of sight operation. In order to extend the range of a typical infrared remote control beyond line of sight, it is possible to combine an IR transmitter and receiver with another component. A hardwired extender unit uses a transmitter and receiver that are connected by a physical wire. This wire can be routed around or through a wall, with the transmitter located in one room and the receiver in another. When a signal is sent to the receiver from a remote control, it travels across the wire and is then turned back into infrared light by the transmitter at the other end. Radio frequency IR extenders perform this same function without any physical wires. These systems involve two components, one of which contains an IR receiver and an RF transmitter. The paired unit contains an RF receiver and IR transmitter. When an infrared remote is used on the IR receiver, the device translates the signal and broadcasts it over RF. The paired unit then receives that signal, decodes it and transmits an IR signal. Infrared transmitter and receiver devices can also be used with some computers. These peripherals are typically designed to connect via universal serial bus (USB) and can be used to control various types of consumer electronics. Software can allow the devices to learn commands directly from other remote control.

Light Emitting Diode:

A light-emitting diode (LED) is semiconductor light source. When a light-emitting diode is forwardbiased (switched on), electrons are able to recombine with electron holes within the device, releasing energy in the form of photons. This effect is called electroluminescence and the color of the light (corresponding to the energy of the photon) is determined by the energy gap of the semiconductor. LEDs powerful enough for room lighting are relatively expensive and require more precise current and heat management than compact fluorescent lamp sources of comparable output. Light-emitting diodes are used in applications as diverse as aviation lighting, automotive lighting, advertising, general lighting, and traffic signals. LEDs have allowed new text, video displays, and sensors to be developed, while their high switching rates are also useful in advanced communications technology. Infrared LEDs are also used in the remote control units of many commercial products including televisions, DVD players and other domestic appliances. LEDs are also used in Seven-segment display.


The Red/Green LED is handy little component that allows two colors (red and green) in a single LED while only having two pins (cathode and anode). The color of the LED depends on the polarity of the connection only allowing one color at a time. Similar LED's that provide two or even three colors usually have three or four pins allowing for a wide range of mixed colors. One would think having two pins is a disadvantage; not so. This LED can easily be applied to a circuit to visually indicate polarity direction.

A preset is a three legged electronic component which can be made to offer varying resistance in a circuit. The resistance is varied by adjusting the rotary control over it. The resistance does not vary linearly but rather varies in exponential or logarithmic manner.

Such variable resistors are commonly used for adjusting sensitivity along with a sensor.The variable resistance is obtained across the single terminal at front and one of the two other terminals. The two legs at back offer fixed resistance which is divided by the front leg. So whenever only the back terminals are used, a preset acts as a fixed resistor. Presets are specified by their fixed value resistance. Working of presets is quite simple. It works by having a resistive track and a small plate having dents to short the track.

This small plate can be rotated using a screw driver or some similar tool. Position of the dents on the track determines the amount of resistance that is to be used in the circuit. Pin Diagram:

Resistor is a passive component used to control current in a circuit. Its resistance is given by the ratio of voltage applied across its terminals to the current passing through it. Resistors can be either fixed or variable. Negative temperature coefficient (NTC), positive temperature coefficient (PTC) and light dependent resistor (LDR) are some such resistors. These special resistors are commonly used as sensors. Read and learn about internal structure and working of a resistor. Pin Diagram:

How to Read Resistor Color Coding Scheme: The resistor color code is always read one band at a time starting from left to the right, with the larger width tolerance band oriented to the right side indicating its tolerance. By matching the color of the first band with its associated number in the digit column of the color chart below, the first digit is identified and this represents the first digit of the resistive value. The second digit of the resistance is obtained by matching again the color of the second band with its associated number in the digit column of the color chart. The tolerance band is usually gold or silver but some may have none.


A capacitor is a passive two terminal component which stores electric charge. This component consists of two conductors which are separated by a dielectric medium. The potential difference when applied across the conductors polarizes the dipole ions to store the charge in the dielectric medium. The circuit symbol of a capacitor is shown below: Pin Diagram:

As you turn on the power supply, the current begins to flow through the capacitor inducing the positive and negative potentials across its plates. The capacitor continues to charge until the capacitor voltage equalizes up to the supply voltage which is called as the charging phase of the capacitor. Once the capacitor is fully charged at the end of this phase, it gets open circuited for DC. It begins to discharge when the power of the capacitor is switched off. There are different types of capacitors. The symbol of capacitors from each group is shown below: Applications: They are so common that it is a rare electrical product that does not include at least one for some purpose. Capacitor is used as energy storage Capacitor are used in pulse powered and weapons Capacitors are used in power conditioning Capacitors are used as noise filter Capacitors are used in tuned circuit Capacitors are used in also sensing the object Capacitors are used in Hazards and in safety product

Oscillator Circuit:
The 8051 uses the crystal for precisely that: to synchronize its operation. Effectively, the 8051 operates using what are called "machine cycles." A single machine cycle is the minimum amount of time in which a single 8051 instruction can be executed. Although many instructions take multiple cycles, 8051 has an on-chip oscillator. It needs an external crystal thats decides the operating frequency of the 8051. This can be achieved in two ways:

. The crystal is connected to pins 18 and 19 with stabilizing capacitors. 12 MHz (11.059MHz) crystal is often used and the capacitance ranges from 20pF to 40pF. The oscillator can also be a TTL clock source connected with a NOT gate.

Introduction: A relay is an electrically operated switch. Current flowing through the coil of the relay creates a magnetic field which attracts a lever and changes the switch contacts. The coil current can be on or off so relays have two switch positions and they are double throw (changeover) switches. Relays allow one circuit to switch a second circuit which can be completely separate from the first. For example a low voltage battery circuit can use a relay to switch a 230V AC mains circuit. There is no electrical connection inside the relay between the two circuits; the link is magnetic and mechanical. The coil of a relay passes a relatively large current, typically 30mA for a 12V relay, but it can be as much as 100mA for relays designed to operate from lower voltages. Circuit Symbol for Relay:

The relay's switch connections are usually labeled COM, NC and NO: COM = Common, always connect to this, it is the moving part of the switch NC = Normally Closed, COM is connected to this when the relay coil is off. NO = Normally Open, COM is connected to this when the relay coil is on. Connect to COM and NO if you want the switched circuit to be on when the relay coil is on. Connect to COM and NC if you want the switched circuit to be on when the relay coil is off.

Advantages & Disadvantage of Relays: Advantages of Relays: Relays can switch AC and DC, transistors can only switch DC. Relays can switch high voltages, transistors cannot.

Relays are a better choice for switching large currents (> 5A) many contacts at once.

Disadvantages of Relays: Relays are bulkier than transistors for switching small currents. cannot switch rapidly (except reed relays), transistors can switch many times per second use more power due to the current flowing through their coil require more current than many ICs can provide, so a low power transistor may be needed to switch the current for the relay's coil. Uses of Relay: To control high current circuits that your existing fuse box can't handle.

Introduction: 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 mutual induction. If a load is connected to the secondary, an electric 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:

By appropriate selection of the ratio of turns, a transformer thus allows an alternating current (AC) voltage to be "stepped up" by making NS greater than NP, or "stepped down" by making NS less than NP.

Basic Principle: The transformer is based on two principles: firstly, that an electric current can produce a magnetic field (electromagnetism) and secondly that a changing magnetic field within a coil of wire induces a voltage across

the ends of the coil (electromagnetic induction). Changing the current in the primary coil changes the magnetic flux that is developed. The changing magnetic flux induces a voltage in the secondary coil. Applications: A major application of transformers is to increase voltage before transmitting electrical energy over long distances through wires. Wires have resistance and so dissipate electrical energy at a rate proportional to the square of the current through the wire. Transformers are also used extensively in electronic products to step down the supply voltage to a level suitable for the low voltage circuits they contain. The transformer also electrically isolates the end user from contact with the supply voltage. Signal and audio transformers are used to couple stages of amplifiers and to match devices such as microphones and record players to the input of amplifiers. Audio transformers allowed telephone circuits to carry on a two-way conversation over a single pair of wires.

Program Code:
#include <REGX51.H> void display(unsigned int); sbit control=P2^7; sbit in=P2^0; sbit out=P2^1; void main(void) { unsigned int z=0; //set counter at zero P1=0XC0; //display zero in all 7segnent display P3=0XC0; P0=0XC0; P2=0X03; control=0; while(1) //repeat forever { if(in==0) // is anybody going inside { while(out==1); while(out==0); z++; //increase the counter display(z); //display no of person control=1; //turn on light } else if(out==0) //is anybody coming outside { while(in==1); while(in==0); z--; //decrease the counter display(z); //display no of person if(z==0) // counter=0? { control=0; //turn off light }

} } } void display(unsigned int m) { unsigned int digit[10]={0XC0,0XF9,0XA4,0XB0,0X99,0x92,0x82,0XF8,0X80,0X90}; unsigned int i,j,k; i=m%10; j=m/10; k=m/100; j=j-k*10; P1=digit[i]; //display lsb P3=digit[j]; //display middle digit P0=digit[k]; //display msb }

Applications & Advantages:

1. This project can be used in various rooms like seminar hall, where the capacity of room is limited and should not be exceeded. Project will display the actual number of persons inside the room. 2. Can be used in class rooms, conference room, and study rooms in colleges. 3. This project can also be used in our home because many times we come out of our bedroom and forgot to turn off the room light. When there is nobody inside the room then lights are turned off, thus this project helps in energy conservation. 4. This project can be used in Cinema halls, multiplex, malls as well as in temples to count the number of person entering inside. So that these places should not get over crowded to avoid congestion

Future Development:
1. Voice alarm system can be added to indicate that room is full & persons cant enter inside. 2. We can increase the maximum number of persons that can be counted by implementing the external EEPROM IC. 2. We can send this data to a remote location using mobile or internet. ______________________