SlideShare a Scribd company logo
DAFFODIL INTERNATIONAL UNIVERSITY
DHAKA, BANGLADESH
PROJECT ON
AUTOMATIC LIGHT CONTROL BY USING MICROCONTROLLER BASED LDR
BY
FARZANA YASMIN
ID: 103-33-335
&
MD. AL MUHAIMIN SARKAR
ID: 102-33-219
SUPERVISED BY
RIFAT ABDULLAH AKHI
SENIOR LECTURER
FACULTY OF ENGINEERING
DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING
Daffodil International University
“THIS REPORT PRESENTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS
FOR THE DEGREE OF BACHELOR OF SCIENCE IN ELECTRICAL AND ELECTRONIC
ENGINEERING”
JUNE 2014
APPROVAL
This project titled “Automatic light control by using microcontroller based LDR”, submitted by
Farzana Yasmin and Md. Al Muhaimin Sarkar to the Department of Electrical and Electronics
Engineering, Daffodil International University, has been accepted as satisfactory for the partial
fulfillment of the requirements for the degree of B.Sc. in Electrical and Electronics Engineering
and approved as to its style and contents. The presentation has been held on.
BOARD OF EXAMINERS
_______________________
Professor Dr. M. Shamsul Alam
Dean and Professor
Department of EEE
Faculty of Engineering
Daffodil International University
_______________________
Dr. Md. Fayzur Rahman
Professor and Head
Department Of EEE
Faculty of Engineering
Daffodil International University
~ i ~
ACKNOWLEDGEMENT
At first we are greatly praise to almighty Allah for successful completion of our undergraduate
project.
We want to thanks our Project Supervisor Rifat Abdullah Akhi, Senior Lecturer, Department of
Electrical and Electronics Engineering, Faculty of Engineering, Daffodil International
University. For her encouragement and for giving us permission to involve with this electronics
project. We have done our project according to his direction. We are also grateful to our
respected teachers.
We thank all staffs of our departmental lab for their help during working period. We are
extremely grateful to our parents, family member and friends for their support, constant love and
sacrifice.
Finally, we beg pardon for our unintentional errors and omission if any.
~ ii ~
DEDICATION
To the person who supported us through the hole life
Thanks to our “Parents” and rest of our family
~ iii ~
ABSTRACT
This paper aims at designing and executing the advanced development in embedded systems for
energy saving of lights. Nowadays, human has become too busy, and is unable to find time even
to switch the lights wherever not necessary. The present system is like the lights will be switched
on in the evening before the sun sets and they are switched off the next day morning after there is
sufficient light on the outside. But the actual timing for these lights to be switched on are when
there is absolute darkness. With this, the power will be wasted up to some extent. This paper
gives the best solution for electrical power wastage. Also the manual operation of the lighting
system is completely eliminated.
CONTENTS
CONTENT NAME PAGE
Acknowledgement i
Dedication ii
Abstract iii
1. CHAPTER-1 INTRODUCTION
1.1Objective 1
1.2 Project Block Diagram 2
1.3 Project Block Diagram Description 2
2. CHAPTER-2 HARDWARE IMPLEMENTATION
2.1 Description of Components 3
2.2 Light Dependent Resistor 3
2.2.1Recovery Rate 5
2.3 Power Supply 6
2.4 Voltage Regulator 6
2.5 Transistor 7
2.6 Resistor 9
2.6.1 Resistor Calculator Instructions 10
2.6.1a Four Band Resistors 11
2.6.1b Five Band Resistors 13
2.7 Capacitor 14
2.8 Diode 15
2.9 Light Emitting Diode(LED) 16
2.10 Relay 17
2.11 Connector 18
2.11a Pin Header Connector 18
2.11b Temporary Connector 19
2.12 ATMEGA8 Microcontroller 19
2.12.1 Pin Description of ATMEGA8 Microcontroller 22
3. CHAPTER-3 DESCRIPTION OF CIRCUIT DIAGRAM
3.1 Automatic Light Control Circuit Design 25
3.2 Part-1(Power input circuit) 26
3.3 Part-2(Operation in LDR and Microcontroller) 27
3.4 Part-3(Output of relay) 33
4 .CHAPTER-4 PRODUCT COST & RESULTS
4.1 Parts List 35
4.2 Product Cost 36
4.3 Advantages & Disadvantages 36
4.3.1 Advantages 36
4.3.2 Disadvantages 37
4.4 Area of Applications 37
4.5 Results And Discussions 38
Future Scope 38
Conclusion 39
References 40
LIST OF FIGURE
FIGURE FIGURE NAME PAGE
Fig 1.1 Project Block-diagram 2
Fig 2.1 LDR 4
Fig 2.1.1 Symbol of LDR 4
Fig 2.2 Practical LDR 5
Fig 2.3 12V DC adapter 6
Fig: 2.4 IC 7805 voltage regulator 7
Fig: 2.5 NPN transistor & symbol of NPN 7
Fig: 2.6 I-V characteristics curve of NPN transistor 8
Fig: 2.7 Resistor 9
Fig: 2.7.1 Symbol of Resistor 9
Fig: 2.7.1a Four Band Resistor color code 11
Fig: 2.7.1b Five & Six band Resistor color code 13
Fig: 2.8 Electrolytic Capacitor 14
Fig: 2.8.1 Ceramic Capacitor 14
Fig: 2.9 Diode 16
Fig: 2.10 LED with symbol 17
Fig: 2.11 Solid state relay 18
Fig: 2.11.1 Protection diode for relay 18
Fig: 2.12.1 Single female pin header 19
Fig: 2.12.2 Double male pin header 19
Fig: 2.12.3 Temporary connector 19
Fig: 2.13 ATMEGA8 Microcontroller 20
Fig: 2.13.1 Pin diagram of ATMEGA8 microcontroller 22
Fig: 3.1 Circuit diagram of automatic light system 25
Fig: 3.2 Power supply circuit 26
Fig: 3.3 Operation in LDR. 27
Fig: 3.3.1 Operation in ATmega8 Microcontroller 28
Fig: 3.4 Output of relay 33
Fig: 3.4.1 When relay NC (ON STATE) 34
Fig: 3.4.2 When relay NO (OFF STATE) 34
Fig: 4 Project on automatic light system 38
LIST OF TABLE
TABLE TABLE NAME PAGE
Table 1 PORTB pin description 23
Table 2 PORTC pin description 23
Table 3 PORTD pin description 24
©Daffodil International University 1
CHAPTER-1
INTRODUCTION
1.1 OBJECTIVE
We need to save or conserve energy because most of the energy sources we depend on,
like coal and natural gas can’t be replaced. Once we use them up they’re gone forever.
Saving power is very important, instead of using the power in unnecessary times it should be
switched off. In this project, we are avoiding the problem by having an automatic system
which turns ON and OFF the lights at given time or when the ambient light falls below a
specific intensity. Each controller has an LDR which is used to detect the ambient light. If
the ambient light is below a specific value the lights are turned ON.
A light dependent sensor is interfaced to the AVR microcontroller it is used to track the
sunlight and when the sensors goes dark the led will be made ON and when the sensors
found light the led will be made OFF.
It clearly demonstrates the working of transistor in saturation region and cut-off region.
The working of relay is also known microcontroller and the code is written in C language in
AVR programmer. Automatic light control is a simple yet powerful concept, which uses
transistor as a switch. By using this system manual works are 100% removed. The aim of
this project is to control the light using LDR. When the light falling occur means resistance
value will be change. There is no light then the resistance value is change. From this
resistance change the voltage variation can be obtained this value is given to ADC of AVR.
AVR is stand for peripheral interface controller.
©Daffodil International University 2
1.2 PROJECT BLOCK DIAGRAM
The system basically consists of a LDR, Power supply, Transistor, Relays and
Microcontroller.
Fig. 1.1: Block diagram of automatic light system.
1.3 BLOCK DIAGRAM DESCRIPTION
The block diagram of automatic light system as shown in fig.1, using the LDR we can
operate the lights. When the light is available then it will be in the OFF state and when it is dark
the light will be in ON state, it means LDR is inversely proportional to light. When the light falls
on the LDR it sends the commands to the microcontroller that it should be in the OFF state then
it switch OFF the light. All this command are sent to the controller then according to that the
device operates. We use a relay to act as an ON/OFF switch.
Regulated power supply
LDR
MICROCONTROLLER
TRANSISTOR RELAY
LAMP
©Daffodil International University 3
CHAPTER-2
HARDWARE IMPLEMENTATION
2.1 DESCRIPTION OF COMPONENTS
In this project the list of hardware components used are given below:
 LDR (Light dependent resistor)
 Power supply
 Voltage regulator
 ATmega8 Microcontroller
 Transistor
 Capacitor
 Resistor
 Diode
 LED(Light emitting diode)
 Relay
 Connector
2.2 LIGHT DEPENDENT RESISTOR
LDRs or Light dependent resistors are very useful especially in light/dark sensor
circuits. Normally the resistance of an LDR is very high, sometimes as high as 1000000 ohms,
but when they are illuminated with light resistance drops dramatically. Electronic onto sensors
are the devices that alter their electrical characteristics, in the presences of visible or invisible
©Daffodil International University 4
light. The best-known devices of this type are the light dependent resistor (LDR), the photo
diode and the phototransistors.
Light dependent resistors as the name suggests depend on light for the variation of resistance.
 LDR are made by depositing a film of cadmium sulphide or cadmium selenide on a
substrate of ceramic containing no or very few free electrons when not illuminated. The
longer the strip the more the value of resistance.
 When light falls on the strip, the resistance decreases. In the absence of light the
resistance can be in the order of 10K ohm to 15K ohm and is called the dark resistance.
Depending on the exposure of light the resistance can fall down to value of 500
ohms. The power ratings are usually smaller and are in the range 50mW to 0.5W. Though
very sensitive to light, the switching time is very high and hence cannot be used for high
frequency applications. They are used in chopper amplifiers. Light dependent resistors
are available as disc 0.5cm to 2.5cm. The resistance rises to several Mega ohms under
dark conditions.
The below figure shows that when the torch is turned on, the resistance of the LDR
falls, allowing current to pass through it is shown in figure.
Fig. 2.1: LDR. Fig. 2.1.1: Symbol of LDR.
The basic construction and symbol for LDR are shown in above figures
respectively. The device consists of a pair of metal film contacts separated by a snakelike
track of cadmium sulphide film, designed to provide the maximum possible contact area
with the two metal films. The structure is housed in a clear plastic or resin case, to
©Daffodil International University 5
provide free access to external light. Practical LDRs are available in variety of sizes and
packages styles, the most popular size having a face diameter of roughly 10mm. practical
LDR is shown in below figure.
Fig. 2.2: Practical LDR
2.2.1 RECOVERY RATE
When an LDR is brought from a certain illuminating level into total darkness, the
resistance does not increase immediately to the dark value. The recovery rate is specified does
not increase immediately to the dark value. The recovery rate is specified in k ohm/second and
for current LDR types it is more than 200K ohm/second. The recovery rate is much greater in the
reverse direction, e.g. going from darkness illumination level of 300 lux, it takes less than 10ms
to reach a resistance which corresponds with a light level of 400 lux. A LDR may be connected
either way round and no special precautions are required when soldering.
 Darkness: Maximum resistance, about 1 Mohm.
 Very bright light: Minimum resistance, about 100 ohm.
The LDR is a variable resistor whose resistance decreases with the increase in light
intensity. Two cadmium sulphide (cds) photoconductive cells with spectral response similar to
that of the human eye. The cell resistance falls with increasing light intensity. Some of its
features:
 High reliability.
 Light weight.
 Wide spectral response.
 Wide ambient temperature range.
©Daffodil International University 6
2.3 POWER SUPPLY
The 12V adapter is connected to the power jack to give the power supply to the relay.
Another 220V power supply connected to the load. To make a 5V Dc regulated power supply we
connected a voltage regulator which give the power supply to the ATmega8 microcontroller and
peripheral items. In the ATmega8 microcontroller the VCC pin is 7th
and GND pin is 8th
. Two
led is also interface to show the status of the power. The 12V adapter image shown in below
figure.
Fig. 2.3: 12V Dc adapter.
2.4 VOLTAGE REGULATOR
Usually, we start with an unregulated power supply ranging from 9volt to 12volt DC.
To make a 5volt power supply, IC 7805 voltage regulator as shown in figure has been used.
©Daffodil International University 7
Fig. 2.4: IC 7805 voltage regulator.
The IC7805 is simple to use. Simply connect the positive lead form unregulated DC power
supply (anything from 9VDC to 12VDC) to the input pin, connect the negative lead to the
common pin and then turn on the power, a 5 volt supply from the output pin will be gotten.
2.5 TRANSISTOR
Solid state switches are one of the main applications for the use of transistors, and
transistor switches can be used for controlling high power devices such as motors, solenoids or
lamps, but they can also used in digital electronics and logic gate circuits. The NPN (PN2222A)
transistor image shown in below figure.
Fig. 2.5: NPN transistor and symbol of NPN transistor.
©Daffodil International University 8
The areas of operation for a transistor switch are known as the Saturation Region and
the Cut-off Region. This means then that we can ignore the operating Q-point biasing and
voltage divider circuitry required for amplification, and use the transistor as a switch by driving
it back and forth between its “fully-OFF” (cut-off) and “fully-ON” (saturation) regions as shown
below.
Fig. 2.6: I-V characteristics curve of NPN transistor.
The pink shaded area at the bottom of the curves represents the “Cut-off” region while
the blue area to the left represents the “Saturation” region of the transistor. Here the operating
conditions of the transistor are zero input base current (IB), zero output collector current ( IC ) and
maximum collector voltage ( VCE ) which results in a large depletion layer and no current
flowing through the device. Therefore the transistor is switched “Fully-OFF”. When the
transistor will be biased so that the maximum amount of base current is applied, resulting in
maximum collector current resulting in the minimum collector emitter voltage drop which results
in the depletion layer being as small as possible and maximum current flowing through the
transistor. Therefore the transistor is switched “Fully-ON”. Then the transistor operates as a
©Daffodil International University 9
“single-pole single-throw” (SPST) solid state switch. With a zero signal applied to the Base of
the transistor it turns “OFF” acting like an open switch and zero collector current flows. With a
positive signal applied to the Base of the transistor it turns “ON” acting like a closed switch and
maximum circuit current flows through the device.
2.6 RESISTOR
A resistor is a passive two-terminal electrical component that implements electrical
resistance as a circuit element. Resistors act to reduce current flow, and, at the same time, act to
lower voltage levels within circuits. The current through a resistor is in direct proportion to
the voltage across the resistor's terminals. This relationship is represented by Ohm's law:
where I is the current through the conductor in units of amperes, Vis the potential difference
measured across the conductor in units of volts, and R is the resistance of the conductor in units
of ohms (symbol: Ω).
Fig. 2.7: Resistor. Fig. 2.7.1: Symbol of resistor. Fig. 2.7FFFF
©Daffodil International University 10
The ratio of the voltage applied across a resistor's terminals to the intensity of current in the
circuit is called its resistance, and this can be assumed to be a constant (independent of the
voltage) for ordinary resistors working within their ratings.
Resistors are common elements of electrical networks and electronic circuits and are ubiquitous
in electronic equipment. Practical resistors can be composed of various compounds and films, as
well as resistance wires (wire made of a high-resistivity alloy, such as nickel-chrome). Resistors
are also implemented within integrated circuits, particularly analog devices, and can also be
integrated into hybrid and printed circuits.
The electrical functionality of a resistor is specified by its resistance: common commercial
resistors are manufactured over a range of more than nine orders of magnitude. When specifying
that resistance in an electronic design, the required precision of the resistance may require
attention to the manufacturing tolerance of the chosen resistor, according to its specific
application. The temperature coefficient of the resistance may also be of concern in some
precision applications. Practical resistors are also specified as having a maximum power rating
which must exceed the anticipated power dissipation of that resistor in a particular circuit: this is
mainly of concern in power electronics applications. Resistors with higher power ratings are
physically larger and may require heat sinks. In a high-voltage circuit, attention must sometimes
be paid to the rated maximum working voltage of the resistor. While there is no minimum
working voltage for a given resistor, failure to account for a resistor's maximum rating may
cause the resistor to incinerate when current is run through it.
2.6.1 RESISTOR CALCULATOR INSTRUCTIONS
This calculator solves for 4, 5 or 6 band resistors and is quite simple to use. To calculate a four
band resistor value, use the middle four "drop" boxes then click on the "Calc 4 Band" button. For
a five or six band resistor, you can use all six boxes but all 6 do not necessarily have to be used -
the "Temperature Coefficient" box, for example. After you have selected the 6 "drop box"
choices, remember to click the "Calc 5 Band" button for your answer. If you have calculated a 5
or 6 band resistor, and go back to calculating a 4 band resistor, the two drop boxes on the ends
(far left and far right) will not clear but this is perfectly all right. When calculating 4 band
©Daffodil International University 11
resistors, the values of the drop boxes on the ends do not enter into the calculations in any
manner.
2.6.1a FOUR BAND RESISTORS
Resistors are electronic components that oppose the flow of electricity and the resistance is
measured in ohms. For larger values, kilo ohms (1,000 ohms) and mega ohms (1,000,000 ohms)
are used. For example 3,300 ohms equals 3.3 kilo ohms or just 3.3 k and 1,500,000 ohms equals
1.5 mega ohms or 1.5 mega.
Color "bands" are used to indicate the resistance value with each color signifying a number and
these color bands are grouped closer to one end of the resistor than the other.
Fig. 2.7.1a: Four Band resistor color code.
©Daffodil International University 12
As can be seen in the above 4 Band Resistor Color Codes chart, the first two color bands have
values of brown = 1, red = 2, orange = 3 and so on.
The third color band is the multiplier of the first 2 bands. Here, black is 1, brown is 10, red is
100 and so on. Putting this in other words, the value of the third band (the multiplier) is the
number 10 raised to the power of the color code. For example, red in the third band is 10² or
100.This third band also has 2 new colors where gold = 0.1 and silver = 0.01.
The 4th band is the resistor's tolerance and shows how precisely the resistor was manufactured.
Gold = 5%, silver = 10% and no band whatsoever = 20%.
Now that we know the values of each color, let's try calculating a few examples of resistance
values.
Looking at resistor 1, we see the colors red red green gold.
The Color Codes chart "translates" this into 2 2 and 100,000
which equals 22 ×100,000 or 2,200,000 ohms and don't forget the gold
4th band which indicates a 5% tolerance.
Resistor 2 has the colors orange orange yellow silver which "translates" into 3 3 ×10,000 or
330,000 ohms and a tolerance of 10%.
Resistor 3 has the colors yellow violet silver meaning 4 7 ×.01 or .47 ohms and no fourth band
indicates a 20% tolerance.
©Daffodil International University 13
2.6.1b FIVE BAND RESISTORS
Fig. 2.7.1b: Five and six band resistor color code.
Use the 5 Band Chart to solve these next problems.
For resistor 4, we see the first 3 bands are violet, green and red which
"translate" into 7, 5 and 2. Looking at the fourth band (the multiplier);
we see it is brown and has a value of 10.
So, the resistance value is 7 5 2 × 10 which equals 7,520 ohms or 7.52 K ohms. Band 5 is red
which indicates a 2 per cent tolerance and a brown sixth band means that the temperature
coefficient is 100 parts per million (ppm).
Examining resistor 5, the first 3 bands are brown, black and blue and the fourth band (the
multiplier) is green. So, these colors convert into 1 0 6 × 100,000 which calculates to 10,600,000
ohms or 10.6 Meg ohms. The brown 5th band and the red 6th band mean that the resistor has a
1% tolerance and a 50 ppm temperature coefficient.
©Daffodil International University 14
If you've read these instructions, you probably have a good understanding of determining a
resistor's value from its colors. Then again, there's always the calculator which makes things
much easier to solve.
2.7 CAPACITOR
A capacitor (originally known as a condenser) is a passive two-terminal electrical
component used to store energy electrically in an electric field. The forms of practical capacitors
vary widely, but all contain at least two electrical conductors (plates) separated by
a dielectric (i.e., insulator). The conductors can be thin films of metal, aluminum foil or disks,
etc. The 'non-conducting' dielectric acts to increase the capacitor's charge capacity. A dielectric
can be glass, ceramic, plastic film, air, paper, mica, etc. Capacitors are widely used as parts
of electrical circuits in many common electrical devices. Unlike a resistor, a capacitor does not
dissipate energy. Instead, a capacitor stores energy in the form of an electrostatic field between
its plates.
Fig. 2.8: Electrolytic Capacitor Fig. 2.8.1: Ceramic Capacitor
When there is a potential difference across the conductors (e.g., when a capacitor is attached
across a battery), an electric field develops across the dielectric, causing positive charge (+Q) to
collect on one plate and negative charge (-Q) to collect on the other plate. If a battery has been
attached to a capacitor for a sufficient amount of time, no current can flow through the capacitor.
©Daffodil International University 15
However, if an accelerating or alternating voltage is applied across the leads of the capacitor,
a displacement current can flow.
An ideal capacitor is characterized by a single constant value for its capacitance. Capacitance is
expressed as the ratio of the electric charge (Q) on each conductor to the potential difference (V)
between them. The capacitance is greater when there is a narrower separation between
conductors and when the conductors have a larger surface area. In practice, the dielectric
between the plates passes a small amount of leakage current and also has an electric field
strength limit, known as the breakdown voltage. The conductors and leads introduce an under
sired inductance and resistance.
Capacitors which have a value of one Farad or more tend to have a solid dielectric and as “One
Farad” is such a large unit to use, prefixes are used instead in electronic formulas with capacitor
values given in micro-Farads (μF), nano-Farads (nF) and the pico-Farads (pF). For example:
Sub-units of the Farad
microfarad, (µF) = F = 1×10-6
F
nanofarad, (nF) = F = 1×10-9
F
picofarad, (pF) = F = 1×10-12
F
2.8 DIODE
A diode is a simple electrical device that allows the flow of current only in one direction. So
it can be said to act somewhat like a switch. A specific arrangement of diodes can convert AC to
pulsating DC, hence it is sometimes also called as a rectifier. It is derived from "di-ode " which
means a device having two electrodes. The symbol of a p-n junction diode is shown below, the
arrowhead points in the direction of conventional current flow. The p-n junction is a basic
building block in any semiconductor device. It is formed by joining a p type (instrinsic
semiconductor doped with a trivalent impurity) and n type semiconductor (intrinsic
semiconductor doped with a pentavalent impurity) together with a special fabrication technique
©Daffodil International University 16
such that a p-n junction is formed. Hence it is a device with two elements, the p-type forms
anode and the n-type forms the cathode. These terminals are brought out to make the external
connections.
Fig. 2.9: DIODE.
The n side will have large number of electrons and very few holes (due to thermal excitation)
whereas the p side will have high concentration of holes and very few electrons. Due to this a
process called diffusion takes place. In this process free electrons from the n side will diffuse
(spread) into the p side and combine with holes present there, leaving a positive immobile (not
moveable) ion in the n side. Hence few atoms on the p side are converted into negative ions.
Similarly few atoms on the n-side will get converted to positive ions. Due to this large number of
positive ions and negative ions will accumulate on the n-side and p-side respectively. This region
so formed is called as depletion region. Due to the presence of these positive and negative ions
a static electric field called as "barrier potential" is created across the p-n junction of the diode.
It is called as "barrier potential" because it acts as a barrier and opposes the flow of positive and
negative ions across the junction.
2.9 LIGHT EMITTING DIODE (LED)
In LED electrical energy is converter in to optical energy. These are example of electro-
luminescence, the process in which emission of photos takes place by the recombination of
excess electrons and holes in a direct band gap semiconductor. The main advantages of using
©Daffodil International University 17
these are the low energy consumption, longer lifetime, strong build, smaller size etc. The LED
images given below.
Fig. 2.10: LED with symbol.
2.10 RELAY
A relay is usually an electromechanical device that is actuated by an electrical current.
The current flowing in one circuit causes the opening or closing of another circuit. Relays are
like remote control switches and are
used in many applications because of
their relative simplicity, long life, and
proven high reliability.
Relays are used in a wide variety of
applications throughout industry, such
as in telephone exchanges, digital
computers and automation systems. Highly sophisticated relays are utilized to protect electric
power systems against trouble and power blackouts as well as to regulate and control the
generation and distribution of power. In the home, relays are used in refrigerators, washing
machines and dishwashers, and heating and air-conditioning controls. Although relays are
generally associated with electrical circuitry, there are many other types, such as pneumatic and
hydraulic. Input may be electrical and output directly mechanical, or vice versa.
©Daffodil International University 18
Fig. 2.11: Electromagnetic relay. Fig.2.11.1: Protection diode for relay.
These active semiconductor devices use light instead of magnetism to actuate a switch. The light
comes from an LED, or light emitting diode.
All relays contain a sensing unit, the electric coil, which is powered by AC or DC current. When
the applied current or voltage exceeds a threshold value, the coil activates the armature, which
operates either to close the open contacts or to open the closed contacts. When a power is
supplied to the coil, it generates a magnetic force that actuates the switch mechanism. The
magnetic force is, in effect, relaying the action from one circuit to another.
2.11 CONNECTOR
Connectors are used to join subsections of circuits together. Usually, a connector is used
where it may be desirable to disconnect the subsections at some future time: power inputs,
peripheral connections, or boards which may need to be replaced. There are different types of
connectors, In this project we used few of them.
2.11a Pin Header Connector
Pin header connectors comprise several different means of connection. Generally, one
side is a series of pins which are soldered to a PCB, and they can either be at a right-angle to the
PCB surface (usually called “straight”) or parallel to the board’s surface (confusingly referred to
©Daffodil International University 19
as “right-angle” pins). Such connectors come in a variety of pitches, and may have any number
of individual rows of pins.
Fig. 2.12.1: Single female pin header. Fig. 2.12.2: Double male pin header.
The most commonly seen pin headers are .1" single or double row connectors. These come in
male and female versions, and are the connectors used to connect PCB boards and shields
together.
2.11b Temporary connector
Screw Terminals
In some cases, it may be desirable to be able to connect bare unterminated wire to a
circuit. Screw terminals provide a good solution for this. They are also good for situations in
which a connection should be capable of supporting multiple different connecting devices.
Temporary connector figure shown in below.
Fig. 2.12.3: Temporary connector.
2.12 ATMEGA8 MICROCONTROLLER
A microcontroller (also microcomputer, MCU or µC) is a small computer on a single
integrated circuit consisting internally of a relatively simple CPU, clock, timers, I/O ports, and
©Daffodil International University 20
memory. Microcontrollers are designed for small or dedicated applications. Microcontrollers are
used in automatically controlled products and devices, such as automobile engine control
systems, remote controls, office machines, appliances, power tools, and toys.
The ATmega8A is a low-power CMOS 8-bit microcontroller based on the AVR RISC
architecture.
By executing powerful instructions in a single clock cycle, the ATmega8A achieves throughputs
approaching 1 MIPS per MHz, allowing the system designer to optimize power consumption
versus processing speed.
It is a High-performance, Low-power AVR® 8-bit Microcontroller having Advanced RISC
Architecture
Fig. 2.13: ATMEGA8 Microcontroller.
Having features like
– 32 x 8 General Purpose Working Registers
– Up to 16 MIPS Throughput at 16 MHz
– 8K Bytes of In-System Self-programmable Flash program memory
– 512 Bytes EEPROM
– 1K Byte Internal SRAM
©Daffodil International University 21
– Write/Erase Cycles: 10,000 Flash/100,000 EEPROM
– Data retention: 20 years at 85°C/100 years at 25°C
– Programming Lock for Software Security
– Two 8-bit Timer/Counters with Separate Prescaler, one Compare Mode
– One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture
– Real Time Counter with Separate Oscillator
– Three PWM Channels
– Programmable Serial USART
– Master/Slave SPI Serial Interface
– Programmable Watchdog Timer with Separate On-chip Oscillator
– On-chip Analog Comparator
- Power-on Reset and Programmable Brown-out Detection
- Internal Calibrated RC Oscillator
- External and Internal Interrupt Sources
- Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and
- 23 Programmable I/O Lines
Operating Voltages 2.7 - 5.5V for ATmega8A
©Daffodil International University 22
2.12.1 Pin description of ATMEGA8 microcontroller
VCC: Digital supply voltage. Magnitude of the voltage range between 4.5V to 5.5V for the
ATmega8.
GND: Ground reference digital voltage.
Fig. 2.13.1: Pin diagram of ATMEGA8 microcontroller.
PORTB (PB7:PB0): PORTB is a port i/o two way (bidirectional) 8-bit with internal
pull-up resistor can be selected. This port output buffers have symmetrical characteristics when
used as an input, the pull-pin low externally will emit a current if the pull-up resistor is activated
it. PORTB pins will be in the condition of the tri-state when RESET is active, although the clock
is not running.
©Daffodil International University 23
Table 1: PORTB pin description.
PORTC (PC5:PC0): PORTC is a port I / O two-way (bidirectional) 7-bit with internal pull-
up resistor can be selected. This port output buffers have symmetrical characteristics when used
as a source or sink. When used as an input, the pull-pin low externally will emit a current if the
pull-up resistor is activated it. PORTC pins will be in the condition of the tri-state when RESET
is active, although the clock is not running.
Table 2: PORTC pin description.
©Daffodil International University 24
PC6/RESET: If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that
the electrical characteristics of PC6 differ from those of the other pins of Port C. If the
RSTDISBL Fuse is not programmed, PC6 is used as a Reset input. A low level on this pin for
longer than the minimum pulse length will generate a Reset, even if the clock is not running.
Port D (PD7:PD0): Port D is an 8-bit bi-directional I/O port with internal pull-up resistors
(selected for each bit). The Port D output buffers have symmetrical drive characteristics with
both high sink and source capability. As inputs, Port D pins that are externally pulled low will
source current if the pull-up resistors are activated.
Table 3: PORTD pin description.
RESET: Reset input. A low level on this pin for longer than the minimum pulse length will
generate a reset, even if the clock is not running.
AVCC: AVCC is the supply voltage pin for the A/D Converter, Port C (3:0), and ADC (7:6). It
should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it
should be connected to VCC through a low-pass filter. Note that Port C (5:4) use digital supply
voltage, VCC.
AREF: AREF is the analog reference pin for the A/D Converter.
©Daffodil International University 25
CHAPTER-3
DESCRIPTION OF CIRCUIT DIAGRAM
3.1 AUTOMATIC LIGHT CONTROL CIRCUIT DESIGN:
The circuit diagram of this project is given below which is draw by Proteus ISP
Professional software.
Fig. 3.1: Circuit diagram of automatic light system.
This is the total circuit diagram sketching. We will define/ discuss this in three part:
©Daffodil International University 26
3.2 Part 1: Power input circuit.
3.3 Part 2: Operation in LDR and Microcontroller.
3.4 Part 3: Output of relay.
In this section we came to know that how the parts connected and how they work. The three
most important sections will describe through this process. In this circuit diagram we used
different electronics parts. They are following: Resistors, Transistor, Capacitors, voltage
regulator, LDR, LED, power supply, microcontroller and relay.
3.2 Part-1(Power input circuit):
In the beginning of making this project we collect our entire component as we make a list. In this
power supply section 12V DC adapter connected with J2. A diode D1 is connected in series with
IC 7805 voltage regulator. Capacitor C2 (100µF) connected with input terminal of IC 7805 and
C3 (10µF) connected with output terminal. C4 (0.1µF) capacitor is connected parallel with C2
and C3. Two pin header male connector embedded parallel of this circuit. Although there is a
diode D3 connected parallel with this power circuit.
Fig. 3.2: Power supply circuit
Here D1 diode is used for give reverse polarity protection to circuit. R3 resistor 10K connected
in series with a LED D2 which indicate the power supply. Diode D3 is used for short circuit
©Daffodil International University 27
protection to microcontroller. The regulated 5V DC supply connected with LDR and ATmega8
microcontroller.
3.3 Part-2(Operation in LDR and Microcontroller):
In this part we connected a LDR in series with R1 (10KΩ) and R2 (100Ω) resistor. Capacitor
C5 (10µF) connected in parallel with LDR.
Fig. 3.3: Operation in LDR.
When light falls on LDR then its resistivity decrease, and when darkness around the LDR
resistivity increases.
The resistivity value is input in ADC5 (28 no. pin) to ATmega8 microcontroller. The output
comes from PB1 (15 no. pin) port of microcontroller. PB0 and PB1 (1 and 2 no pin) port is
connected with a single female pin header connector which can debug this circuit. AVCC and
AREF port (20 and 21 no. pin) connected with a capacitor C1(100nF) in series. Pin 7 and 8
connected for VCC and GND connection of ATmega8 microcontroller.
©Daffodil International University 28
Fig. 3.3.1: Operation in ATmega8 Microcontroller.
ATmega8 microcontroller give signal to transistor. It has programmed by AVR programmer.
The program is given below:
Chip type : ATmega8L
Program type : Application
AVR Core Clock frequency: 8.000000 MHz
Memory model : Small
External RAM size : 0
Data Stack size : 256
*****************************************************/
©Daffodil International University 29
#include <mega8.h>
#include <delay.h>
// Standard Input/Output functions
#include <stdio.h>
//////////////////////////////////
//Programmer Setting
#define relay PORTB.1
#define ON 1
#define OFF 0
/////////////////////////////////
////////////////////////////////
//User Setting
#define Dark 800
#define Light 600
/////////////////////////////////
#define ADC_VREF_TYPE 0x00
// Read the AD conversion result
unsigned int read_adc(unsigned char adc_input)
{
©Daffodil International University 30
ADMUX=adc_input | (ADC_VREF_TYPE & 0xff);
// Delay needed for the stabilization of the ADC input voltage
delay_us(10);
// Start the AD conversion
ADCSRA|=0x40;
// Wait for the AD conversion to complete
while ((ADCSRA & 0x10)==0);
ADCSRA|=0x10;
return ADCW;
}
// Declare your global variables here
unsigned int adc=0;
void main(void)
{
// Declare your local variables here
// Input/Output Ports initialization
// Port B initialization
// Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=Out
// State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=0
©Daffodil International University 31
PORTB=0x00;
DDRB=0x02;
// USART initialization
// Communication Parameters: 8 Data, 1 Stop, No Parity
// USART Receiver: On
// USART Transmitter: On
// USART Mode: Asynchronous
// USART Baud Rate: 9600
UCSRA=0x00;
UCSRB=0x18;
UCSRC=0x86;
UBRRH=0x00;
UBRRL=0x33;
// ADC initialization
// ADC Clock frequency: 62.500 kHz
// ADC Voltage Reference: AREF pin
ADMUX=ADC_VREF_TYPE & 0xff;
ADCSRA=0x87;
printf("LDR Based AC Light Control Projectrn");
©Daffodil International University 32
printf("Designed By farzana muhaiminrn");
delay_ms(1000);
while (1)
{
// Place your code here
adc=read_adc(5);
delay_ms(100);
printf("LDR=%drn",adc);
delay_ms(500);
if(adc>Dark)// if darkness
{
delay_ms(10);
relay=ON;
}
if(adc<Light)// if day light
{
delay_ms(10);
relay=OFF;
©Daffodil International University 33
This program install in microcontroller. If the light resistivity around 600 then it gives signal to
relay OFF and resistivity 800 then it gives signal to relay ON.
3.4 Part-3(Output of relay):
In this part 12V DC power supply connected with a relay. A transistor is connected with a
output of microcontroller. Transistor is connected in series with a resistor R36 (4.7KΩ). D9 is
connected parallel with relay coil. Temporary Connector J30 is connected with relay contacts.
Fig. 3.4: Output of relay.
As the current flows through the coil a self induced magnetic field is generated around it. When
the current in the coil is turned “OFF”, a large back e.m.f (electromotive force) voltage is
produced as the magnetic flux collapses within the coil. This induced reverse voltage value may
be very high in comparison to the switching voltage, and may damage any semiconductor device
©Daffodil International University 34
such as a transistor, FET or micro-controller used to operate the relay coil. One way of
preventing damage to the transistor or any switching semiconductor device, is to connect a
reverse biased diode across the relay coil.
When the current flowing through the coil is switched “OFF”, an induced back emf is generated
as the magnetic flux collapses in the coil.
This reverse voltage forward biases the diode which conducts and dissipates the stored energy
preventing any damage to the semiconductor transistor.
When used in this type of application the diode is generally known as a Flywheel Diode, Free-
wheeling Diode and even Fly-back Diode, but they all mean the same thing.
Fig. 3.4.1: When relay NO (ON STATE). Fig. 3.4.2: When relay NC (OFF STATE).
A LED D24 and resistor R43 (470Ω) connected in series with 12V dc power supply and D24
shows status of relay ON and OFF condition.
CHAPTER-4
PRODUCT COST AND RESULTS
©Daffodil International University 35
4.1 PARTS LIST
The name of parts used in this project are given below:
NAME OF PARTS QUALITY QUANTITY
Capacitors
100nF 2
C1, C4
C2 100µF 1
C3, C5 10µF 2
Resistors
10KΩ 2
R1, R3
R2 100Ω 1
R36 4.7KΩ 1
R43 470Ω 1
Diodes
1N4007 3
D1,D3,D4
LED(D2, D24) LED-GREEN 2
LDR TORCH-LDR 1
Connectors
CONN-SIL2 2
J1, J4
J2 TBLOCK M-2 1
J3 CONN-SIL5 1
J30 TBLOCK I3 1
Transistor PN2222 1
Voltage regulator (U2) IC 7805 1
Microcontroller (U1) ATmega8 1
Relay OMIH-SH-124D 1
4.2 PRODUCT COST
©Daffodil International University 36
The total cost of this project is given below:
PARTS AND MATERIALS ITEM COST (in BDT)
Capacitors 10Tk
Resistors 10Tk
LDR 20Tk
Diodes 10Tk
LED 8Tk
Transistor 10Tk
ATmega8 microcontroller 150Tk
Voltage regulator 20Tk
Connectors 35Tk
Relay 20Tk
Plug 20Tk
12V DC adaptor 100Tk
Lamp with holder and switch 240Tk
PCB design 200Tk
TOTAL COST 853TK.
4.3 ADVANTAGES AND DISADVANTAGES
4.3.1 Advantages:
 LDRs are sensitive, inexpensive and readily available devices. They have good power
and voltage handling capabilities, similar to those of a conventional resistor.
 They are small enough to fit into virtually any electronic device and used all around the
world as a basis component in many electrical systems.
©Daffodil International University 37
4.3.2 Disadvantages:
 It is sensitive to ambient light and require careful shielding.
 Can be more complicated to align detector pairs.
4.4 AREA OF APPLICATIONS
 It can be used in some clocks, alarms, and other electronic devices that are dependent
on sunlight.
 We can used it outside of house, corridors or industry area, which helps to save
power.
 It can be used as a street light.
 In sea off-shore side we can use it as a dangerous sign
©Daffodil International University 38
4.5 RESULTS AND DISCUSSIONS
The project aims were to reduce the side effects of the current lighting system, and find a
solution to save power. In this project the first thing to do, is to prepare the inputs and outputs of
the system to control the lights. The project shown in Fig.4 has been implemented and works as
expected and will prove to be very useful.
Fig. 4: Project on automatic light system.
FUTURE SCOPE
The above project we can develop solar street light system with Automatic street light
controller. The system can be powered from a battery, which can be charged during day time by
harvesting the solar energy through a solar cell. The solar energy harvested from sunlight can be
stored, inverted from DC voltages to AC voltage using sun tie converter.
©Daffodil International University 39
The AC voltage can be stepped down rectified and using the circuit. The above mentioned
strategy will enable us to harvest solar energy in an effective way for the operation of the circuit
and for powering the street light also.
CONCLUSION
This paper elaborates the design and construction of automatic light control system circuit.
Circuit works properly to turn lamp ON/OFF. LDR sensor is the main conditions in working the
circuit. If the conditions have been satisfied the circuit will do the desired work according to
specific program. Each sensor controls the turning ON or OFF the lighting column. The lights
has been successfully controlled by microcontroller. With commands from the controller the
lights will be ON in the places of the movement when it's dark. Finally this control circuit can be
used in various purposes.
©Daffodil International University 40
REFERENCES
[1] M. A. Wazed, N. Nafis, M. T. Islam and A. S. M. Sayem, Design and Fabrication of
Automatic Street Light Control System, Engineering e-Transaction, Vol. 5, No. 1, June 2010, pp
27-34.
[2] K.Y. Rajput, G. Khatav, M. Pujari, P. Yadav, Intelligent Street Lighting System Using Gsm,
International Journal of Engineering Science Invention, Vol2, Issue 3, March 2013, PP. 60- 69.
[3] D. A. Devi and A. Kumar, Design and Implementation of CPLD based Solar Power Saving
System for Street Lights and Automatic Traffic Controller, International Journal of Scientific and
Research Publications, Vol. 2, Issue11, November 2012.
[4] K. S. Sudhakar, A. A. Anil, K. C. Ashok and S. S. Bhaskar, Automatic Street Light Control
System, International Journal of Emerging Technology and Advanced Engineering, Vol. 3, May
2013, PP. 188-189.
[5] Programming and Customizing The AVR Microcontroller by Dhananjay V. Gadre
[6] Programming 16-bit Microcontrollers in C by Lucio Di Jasio
[7] Power Electronics(circuits, devices and applications) 3rd edition By M H Rashid
[8] Electronic Devices and Circuit Theory - Robert Boylestad & Louis Nashelsky - 7th Edition
[9] An Introduction to programming an Atmega microcontroller By Benjamin Reh
[10] W. Bolton. Instrumentation and Control Systems, Elsevier Science & Technology Books,
August 2004.
Internet sources:
http://www.electronics-tutorials.ws/io/io_5.html
http://www.kanda.com/blog/microcontrollers/avr-microcontrollers/avr-microcontroller/
http://www.circuitstoday.com/category/voltage-regulators
©Daffodil International University 41

More Related Content

PDF
A Journey Towards Fully Immersive Media Access
PPTX
Data leakage detection
PPTX
Tranmisi Data Dan Analog
PDF
Antena dan Propagasi Gelombang
PPTX
what is data security full ppt
PPTX
WWW, WEB BROWSER AND SEARCH ENGINE
PPT
Opto electronics devices
PPTX
Facebook Forensics Toolkit(FFT)
A Journey Towards Fully Immersive Media Access
Data leakage detection
Tranmisi Data Dan Analog
Antena dan Propagasi Gelombang
what is data security full ppt
WWW, WEB BROWSER AND SEARCH ENGINE
Opto electronics devices
Facebook Forensics Toolkit(FFT)

Similar to AUTOMATIC LIGHT CONTROL BY USING MICROCONTROLLER BASED LDR (20)

PPTX
Street light controlling using Microcontroller
PPT
372269780-Ppt-Automatic-Street-Light.ppt
PPTX
STREET LIGHT THAT GLOWS ON DETECTING VEHICLE MOVEMENT
PDF
International Journal of Engineering Research and Development
PDF
MINOR PROJECT automated street light
PDF
AUTOMATED LIGHT CONTROL SYSTEM FOR OFFICES
PPTX
Indus university
PDF
AUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUIT
PPTX
Investigation project on physics class 12.pptx
PDF
Otema 11
PDF
Automatic sreet light شروع1 1
PPTX
AUTOMATIC WINDOW BLINKS CONTROLLING USING LDR.pptx
PDF
aut street light ppt.pdf
PPTX
Presentation1
PPTX
Ppt engineering study material available
PPTX
Automatic light control Using LDR
PDF
Automatic street light control using LDR.
PDF
Automatic street light control using LDR.
PDF
International Journal of Engineering Research and Development
PPTX
automatic light control at night ppt by Shubhan raj
Street light controlling using Microcontroller
372269780-Ppt-Automatic-Street-Light.ppt
STREET LIGHT THAT GLOWS ON DETECTING VEHICLE MOVEMENT
International Journal of Engineering Research and Development
MINOR PROJECT automated street light
AUTOMATED LIGHT CONTROL SYSTEM FOR OFFICES
Indus university
AUTOMATIC LIGHT & DARK SENSING SYSTEM WITH MOSQUITO REPELLENT CIRCUIT
Investigation project on physics class 12.pptx
Otema 11
Automatic sreet light شروع1 1
AUTOMATIC WINDOW BLINKS CONTROLLING USING LDR.pptx
aut street light ppt.pdf
Presentation1
Ppt engineering study material available
Automatic light control Using LDR
Automatic street light control using LDR.
Automatic street light control using LDR.
International Journal of Engineering Research and Development
automatic light control at night ppt by Shubhan raj
Ad

More from Nathan Mathis (20)

PDF
Page Borders Design, Border Design, Baby Clip Art, Fre
PDF
How To Write Your Essays In Less Minutes Using This Website Doy News
PDF
Lined Paper For Beginning Writers Writing Paper Prin
PDF
Term Paper Example Telegraph
PDF
Unusual How To Start Off A Compare And Contrast Essay
PDF
How To Write A Methodology Essay, Essay Writer, Essa
PDF
Recolectar 144 Imagem Educational Background Ex
PDF
Microsoft Word Lined Paper Template
PDF
Owl Writing Paper
PDF
The Essay Writing Process Essays
PDF
How To Make A Cover Page For Assignment Guide - As
PDF
Awesome Creative Writing Essays Thatsnotus
PDF
Sites That Write Papers For You. Websites That Write Essays For You
PDF
4.4 How To Organize And Arrange - Hu
PDF
Essay Written In First Person
PDF
My Purpose In Life Free Essay Example
PDF
The Structure Of An Outline For A Research Paper, Including Text
PDF
What Are Some Topics For Exemplification Essays - Quora
PDF
Please Comment, Like, Or Re-Pin For Later Bibliogra
PDF
Ide Populer Word In English, Top
Page Borders Design, Border Design, Baby Clip Art, Fre
How To Write Your Essays In Less Minutes Using This Website Doy News
Lined Paper For Beginning Writers Writing Paper Prin
Term Paper Example Telegraph
Unusual How To Start Off A Compare And Contrast Essay
How To Write A Methodology Essay, Essay Writer, Essa
Recolectar 144 Imagem Educational Background Ex
Microsoft Word Lined Paper Template
Owl Writing Paper
The Essay Writing Process Essays
How To Make A Cover Page For Assignment Guide - As
Awesome Creative Writing Essays Thatsnotus
Sites That Write Papers For You. Websites That Write Essays For You
4.4 How To Organize And Arrange - Hu
Essay Written In First Person
My Purpose In Life Free Essay Example
The Structure Of An Outline For A Research Paper, Including Text
What Are Some Topics For Exemplification Essays - Quora
Please Comment, Like, Or Re-Pin For Later Bibliogra
Ide Populer Word In English, Top
Ad

Recently uploaded (20)

PPTX
Lesson notes of climatology university.
PPTX
master seminar digital applications in india
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Cell Structure & Organelles in detailed.
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PDF
O7-L3 Supply Chain Operations - ICLT Program
PPTX
Pharmacology of Heart Failure /Pharmacotherapy of CHF
PDF
Anesthesia in Laparoscopic Surgery in India
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
RMMM.pdf make it easy to upload and study
PDF
Classroom Observation Tools for Teachers
PDF
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
PDF
Microbial disease of the cardiovascular and lymphatic systems
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Lesson notes of climatology university.
master seminar digital applications in india
STATICS OF THE RIGID BODIES Hibbelers.pdf
Saundersa Comprehensive Review for the NCLEX-RN Examination.pdf
Abdominal Access Techniques with Prof. Dr. R K Mishra
Cell Structure & Organelles in detailed.
202450812 BayCHI UCSC-SV 20250812 v17.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
102 student loan defaulters named and shamed – Is someone you know on the list?
O7-L3 Supply Chain Operations - ICLT Program
Pharmacology of Heart Failure /Pharmacotherapy of CHF
Anesthesia in Laparoscopic Surgery in India
Chinmaya Tiranga quiz Grand Finale.pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
Final Presentation General Medicine 03-08-2024.pptx
RMMM.pdf make it easy to upload and study
Classroom Observation Tools for Teachers
The Lost Whites of Pakistan by Jahanzaib Mughal.pdf
Microbial disease of the cardiovascular and lymphatic systems
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx

AUTOMATIC LIGHT CONTROL BY USING MICROCONTROLLER BASED LDR

  • 1. DAFFODIL INTERNATIONAL UNIVERSITY DHAKA, BANGLADESH PROJECT ON AUTOMATIC LIGHT CONTROL BY USING MICROCONTROLLER BASED LDR BY FARZANA YASMIN ID: 103-33-335 & MD. AL MUHAIMIN SARKAR ID: 102-33-219 SUPERVISED BY RIFAT ABDULLAH AKHI SENIOR LECTURER FACULTY OF ENGINEERING DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING Daffodil International University “THIS REPORT PRESENTED IN PARTIAL FULFILLMENT OF THE REQUIREMENTS FOR THE DEGREE OF BACHELOR OF SCIENCE IN ELECTRICAL AND ELECTRONIC ENGINEERING” JUNE 2014
  • 2. APPROVAL This project titled “Automatic light control by using microcontroller based LDR”, submitted by Farzana Yasmin and Md. Al Muhaimin Sarkar to the Department of Electrical and Electronics Engineering, Daffodil International University, has been accepted as satisfactory for the partial fulfillment of the requirements for the degree of B.Sc. in Electrical and Electronics Engineering and approved as to its style and contents. The presentation has been held on. BOARD OF EXAMINERS _______________________ Professor Dr. M. Shamsul Alam Dean and Professor Department of EEE Faculty of Engineering Daffodil International University _______________________ Dr. Md. Fayzur Rahman Professor and Head Department Of EEE Faculty of Engineering Daffodil International University
  • 3. ~ i ~ ACKNOWLEDGEMENT At first we are greatly praise to almighty Allah for successful completion of our undergraduate project. We want to thanks our Project Supervisor Rifat Abdullah Akhi, Senior Lecturer, Department of Electrical and Electronics Engineering, Faculty of Engineering, Daffodil International University. For her encouragement and for giving us permission to involve with this electronics project. We have done our project according to his direction. We are also grateful to our respected teachers. We thank all staffs of our departmental lab for their help during working period. We are extremely grateful to our parents, family member and friends for their support, constant love and sacrifice. Finally, we beg pardon for our unintentional errors and omission if any.
  • 4. ~ ii ~ DEDICATION To the person who supported us through the hole life Thanks to our “Parents” and rest of our family
  • 5. ~ iii ~ ABSTRACT This paper aims at designing and executing the advanced development in embedded systems for energy saving of lights. Nowadays, human has become too busy, and is unable to find time even to switch the lights wherever not necessary. The present system is like the lights will be switched on in the evening before the sun sets and they are switched off the next day morning after there is sufficient light on the outside. But the actual timing for these lights to be switched on are when there is absolute darkness. With this, the power will be wasted up to some extent. This paper gives the best solution for electrical power wastage. Also the manual operation of the lighting system is completely eliminated.
  • 6. CONTENTS CONTENT NAME PAGE Acknowledgement i Dedication ii Abstract iii 1. CHAPTER-1 INTRODUCTION 1.1Objective 1 1.2 Project Block Diagram 2 1.3 Project Block Diagram Description 2 2. CHAPTER-2 HARDWARE IMPLEMENTATION 2.1 Description of Components 3 2.2 Light Dependent Resistor 3 2.2.1Recovery Rate 5 2.3 Power Supply 6 2.4 Voltage Regulator 6 2.5 Transistor 7 2.6 Resistor 9 2.6.1 Resistor Calculator Instructions 10 2.6.1a Four Band Resistors 11 2.6.1b Five Band Resistors 13
  • 7. 2.7 Capacitor 14 2.8 Diode 15 2.9 Light Emitting Diode(LED) 16 2.10 Relay 17 2.11 Connector 18 2.11a Pin Header Connector 18 2.11b Temporary Connector 19 2.12 ATMEGA8 Microcontroller 19 2.12.1 Pin Description of ATMEGA8 Microcontroller 22 3. CHAPTER-3 DESCRIPTION OF CIRCUIT DIAGRAM 3.1 Automatic Light Control Circuit Design 25 3.2 Part-1(Power input circuit) 26 3.3 Part-2(Operation in LDR and Microcontroller) 27 3.4 Part-3(Output of relay) 33 4 .CHAPTER-4 PRODUCT COST & RESULTS 4.1 Parts List 35 4.2 Product Cost 36 4.3 Advantages & Disadvantages 36 4.3.1 Advantages 36 4.3.2 Disadvantages 37 4.4 Area of Applications 37
  • 8. 4.5 Results And Discussions 38 Future Scope 38 Conclusion 39 References 40
  • 9. LIST OF FIGURE FIGURE FIGURE NAME PAGE Fig 1.1 Project Block-diagram 2 Fig 2.1 LDR 4 Fig 2.1.1 Symbol of LDR 4 Fig 2.2 Practical LDR 5 Fig 2.3 12V DC adapter 6 Fig: 2.4 IC 7805 voltage regulator 7 Fig: 2.5 NPN transistor & symbol of NPN 7 Fig: 2.6 I-V characteristics curve of NPN transistor 8 Fig: 2.7 Resistor 9 Fig: 2.7.1 Symbol of Resistor 9 Fig: 2.7.1a Four Band Resistor color code 11 Fig: 2.7.1b Five & Six band Resistor color code 13 Fig: 2.8 Electrolytic Capacitor 14 Fig: 2.8.1 Ceramic Capacitor 14 Fig: 2.9 Diode 16 Fig: 2.10 LED with symbol 17 Fig: 2.11 Solid state relay 18 Fig: 2.11.1 Protection diode for relay 18 Fig: 2.12.1 Single female pin header 19 Fig: 2.12.2 Double male pin header 19 Fig: 2.12.3 Temporary connector 19 Fig: 2.13 ATMEGA8 Microcontroller 20 Fig: 2.13.1 Pin diagram of ATMEGA8 microcontroller 22
  • 10. Fig: 3.1 Circuit diagram of automatic light system 25 Fig: 3.2 Power supply circuit 26 Fig: 3.3 Operation in LDR. 27 Fig: 3.3.1 Operation in ATmega8 Microcontroller 28 Fig: 3.4 Output of relay 33 Fig: 3.4.1 When relay NC (ON STATE) 34 Fig: 3.4.2 When relay NO (OFF STATE) 34 Fig: 4 Project on automatic light system 38
  • 11. LIST OF TABLE TABLE TABLE NAME PAGE Table 1 PORTB pin description 23 Table 2 PORTC pin description 23 Table 3 PORTD pin description 24
  • 12. ©Daffodil International University 1 CHAPTER-1 INTRODUCTION 1.1 OBJECTIVE We need to save or conserve energy because most of the energy sources we depend on, like coal and natural gas can’t be replaced. Once we use them up they’re gone forever. Saving power is very important, instead of using the power in unnecessary times it should be switched off. In this project, we are avoiding the problem by having an automatic system which turns ON and OFF the lights at given time or when the ambient light falls below a specific intensity. Each controller has an LDR which is used to detect the ambient light. If the ambient light is below a specific value the lights are turned ON. A light dependent sensor is interfaced to the AVR microcontroller it is used to track the sunlight and when the sensors goes dark the led will be made ON and when the sensors found light the led will be made OFF. It clearly demonstrates the working of transistor in saturation region and cut-off region. The working of relay is also known microcontroller and the code is written in C language in AVR programmer. Automatic light control is a simple yet powerful concept, which uses transistor as a switch. By using this system manual works are 100% removed. The aim of this project is to control the light using LDR. When the light falling occur means resistance value will be change. There is no light then the resistance value is change. From this resistance change the voltage variation can be obtained this value is given to ADC of AVR. AVR is stand for peripheral interface controller.
  • 13. ©Daffodil International University 2 1.2 PROJECT BLOCK DIAGRAM The system basically consists of a LDR, Power supply, Transistor, Relays and Microcontroller. Fig. 1.1: Block diagram of automatic light system. 1.3 BLOCK DIAGRAM DESCRIPTION The block diagram of automatic light system as shown in fig.1, using the LDR we can operate the lights. When the light is available then it will be in the OFF state and when it is dark the light will be in ON state, it means LDR is inversely proportional to light. When the light falls on the LDR it sends the commands to the microcontroller that it should be in the OFF state then it switch OFF the light. All this command are sent to the controller then according to that the device operates. We use a relay to act as an ON/OFF switch. Regulated power supply LDR MICROCONTROLLER TRANSISTOR RELAY LAMP
  • 14. ©Daffodil International University 3 CHAPTER-2 HARDWARE IMPLEMENTATION 2.1 DESCRIPTION OF COMPONENTS In this project the list of hardware components used are given below:  LDR (Light dependent resistor)  Power supply  Voltage regulator  ATmega8 Microcontroller  Transistor  Capacitor  Resistor  Diode  LED(Light emitting diode)  Relay  Connector 2.2 LIGHT DEPENDENT RESISTOR LDRs or Light dependent resistors are very useful especially in light/dark sensor circuits. Normally the resistance of an LDR is very high, sometimes as high as 1000000 ohms, but when they are illuminated with light resistance drops dramatically. Electronic onto sensors are the devices that alter their electrical characteristics, in the presences of visible or invisible
  • 15. ©Daffodil International University 4 light. The best-known devices of this type are the light dependent resistor (LDR), the photo diode and the phototransistors. Light dependent resistors as the name suggests depend on light for the variation of resistance.  LDR are made by depositing a film of cadmium sulphide or cadmium selenide on a substrate of ceramic containing no or very few free electrons when not illuminated. The longer the strip the more the value of resistance.  When light falls on the strip, the resistance decreases. In the absence of light the resistance can be in the order of 10K ohm to 15K ohm and is called the dark resistance. Depending on the exposure of light the resistance can fall down to value of 500 ohms. The power ratings are usually smaller and are in the range 50mW to 0.5W. Though very sensitive to light, the switching time is very high and hence cannot be used for high frequency applications. They are used in chopper amplifiers. Light dependent resistors are available as disc 0.5cm to 2.5cm. The resistance rises to several Mega ohms under dark conditions. The below figure shows that when the torch is turned on, the resistance of the LDR falls, allowing current to pass through it is shown in figure. Fig. 2.1: LDR. Fig. 2.1.1: Symbol of LDR. The basic construction and symbol for LDR are shown in above figures respectively. The device consists of a pair of metal film contacts separated by a snakelike track of cadmium sulphide film, designed to provide the maximum possible contact area with the two metal films. The structure is housed in a clear plastic or resin case, to
  • 16. ©Daffodil International University 5 provide free access to external light. Practical LDRs are available in variety of sizes and packages styles, the most popular size having a face diameter of roughly 10mm. practical LDR is shown in below figure. Fig. 2.2: Practical LDR 2.2.1 RECOVERY RATE When an LDR is brought from a certain illuminating level into total darkness, the resistance does not increase immediately to the dark value. The recovery rate is specified does not increase immediately to the dark value. The recovery rate is specified in k ohm/second and for current LDR types it is more than 200K ohm/second. The recovery rate is much greater in the reverse direction, e.g. going from darkness illumination level of 300 lux, it takes less than 10ms to reach a resistance which corresponds with a light level of 400 lux. A LDR may be connected either way round and no special precautions are required when soldering.  Darkness: Maximum resistance, about 1 Mohm.  Very bright light: Minimum resistance, about 100 ohm. The LDR is a variable resistor whose resistance decreases with the increase in light intensity. Two cadmium sulphide (cds) photoconductive cells with spectral response similar to that of the human eye. The cell resistance falls with increasing light intensity. Some of its features:  High reliability.  Light weight.  Wide spectral response.  Wide ambient temperature range.
  • 17. ©Daffodil International University 6 2.3 POWER SUPPLY The 12V adapter is connected to the power jack to give the power supply to the relay. Another 220V power supply connected to the load. To make a 5V Dc regulated power supply we connected a voltage regulator which give the power supply to the ATmega8 microcontroller and peripheral items. In the ATmega8 microcontroller the VCC pin is 7th and GND pin is 8th . Two led is also interface to show the status of the power. The 12V adapter image shown in below figure. Fig. 2.3: 12V Dc adapter. 2.4 VOLTAGE REGULATOR Usually, we start with an unregulated power supply ranging from 9volt to 12volt DC. To make a 5volt power supply, IC 7805 voltage regulator as shown in figure has been used.
  • 18. ©Daffodil International University 7 Fig. 2.4: IC 7805 voltage regulator. The IC7805 is simple to use. Simply connect the positive lead form unregulated DC power supply (anything from 9VDC to 12VDC) to the input pin, connect the negative lead to the common pin and then turn on the power, a 5 volt supply from the output pin will be gotten. 2.5 TRANSISTOR Solid state switches are one of the main applications for the use of transistors, and transistor switches can be used for controlling high power devices such as motors, solenoids or lamps, but they can also used in digital electronics and logic gate circuits. The NPN (PN2222A) transistor image shown in below figure. Fig. 2.5: NPN transistor and symbol of NPN transistor.
  • 19. ©Daffodil International University 8 The areas of operation for a transistor switch are known as the Saturation Region and the Cut-off Region. This means then that we can ignore the operating Q-point biasing and voltage divider circuitry required for amplification, and use the transistor as a switch by driving it back and forth between its “fully-OFF” (cut-off) and “fully-ON” (saturation) regions as shown below. Fig. 2.6: I-V characteristics curve of NPN transistor. The pink shaded area at the bottom of the curves represents the “Cut-off” region while the blue area to the left represents the “Saturation” region of the transistor. Here the operating conditions of the transistor are zero input base current (IB), zero output collector current ( IC ) and maximum collector voltage ( VCE ) which results in a large depletion layer and no current flowing through the device. Therefore the transistor is switched “Fully-OFF”. When the transistor will be biased so that the maximum amount of base current is applied, resulting in maximum collector current resulting in the minimum collector emitter voltage drop which results in the depletion layer being as small as possible and maximum current flowing through the transistor. Therefore the transistor is switched “Fully-ON”. Then the transistor operates as a
  • 20. ©Daffodil International University 9 “single-pole single-throw” (SPST) solid state switch. With a zero signal applied to the Base of the transistor it turns “OFF” acting like an open switch and zero collector current flows. With a positive signal applied to the Base of the transistor it turns “ON” acting like a closed switch and maximum circuit current flows through the device. 2.6 RESISTOR A resistor is a passive two-terminal electrical component that implements electrical resistance as a circuit element. Resistors act to reduce current flow, and, at the same time, act to lower voltage levels within circuits. The current through a resistor is in direct proportion to the voltage across the resistor's terminals. This relationship is represented by Ohm's law: where I is the current through the conductor in units of amperes, Vis the potential difference measured across the conductor in units of volts, and R is the resistance of the conductor in units of ohms (symbol: Ω). Fig. 2.7: Resistor. Fig. 2.7.1: Symbol of resistor. Fig. 2.7FFFF
  • 21. ©Daffodil International University 10 The ratio of the voltage applied across a resistor's terminals to the intensity of current in the circuit is called its resistance, and this can be assumed to be a constant (independent of the voltage) for ordinary resistors working within their ratings. Resistors are common elements of electrical networks and electronic circuits and are ubiquitous in electronic equipment. Practical resistors can be composed of various compounds and films, as well as resistance wires (wire made of a high-resistivity alloy, such as nickel-chrome). Resistors are also implemented within integrated circuits, particularly analog devices, and can also be integrated into hybrid and printed circuits. The electrical functionality of a resistor is specified by its resistance: common commercial resistors are manufactured over a range of more than nine orders of magnitude. When specifying that resistance in an electronic design, the required precision of the resistance may require attention to the manufacturing tolerance of the chosen resistor, according to its specific application. The temperature coefficient of the resistance may also be of concern in some precision applications. Practical resistors are also specified as having a maximum power rating which must exceed the anticipated power dissipation of that resistor in a particular circuit: this is mainly of concern in power electronics applications. Resistors with higher power ratings are physically larger and may require heat sinks. In a high-voltage circuit, attention must sometimes be paid to the rated maximum working voltage of the resistor. While there is no minimum working voltage for a given resistor, failure to account for a resistor's maximum rating may cause the resistor to incinerate when current is run through it. 2.6.1 RESISTOR CALCULATOR INSTRUCTIONS This calculator solves for 4, 5 or 6 band resistors and is quite simple to use. To calculate a four band resistor value, use the middle four "drop" boxes then click on the "Calc 4 Band" button. For a five or six band resistor, you can use all six boxes but all 6 do not necessarily have to be used - the "Temperature Coefficient" box, for example. After you have selected the 6 "drop box" choices, remember to click the "Calc 5 Band" button for your answer. If you have calculated a 5 or 6 band resistor, and go back to calculating a 4 band resistor, the two drop boxes on the ends (far left and far right) will not clear but this is perfectly all right. When calculating 4 band
  • 22. ©Daffodil International University 11 resistors, the values of the drop boxes on the ends do not enter into the calculations in any manner. 2.6.1a FOUR BAND RESISTORS Resistors are electronic components that oppose the flow of electricity and the resistance is measured in ohms. For larger values, kilo ohms (1,000 ohms) and mega ohms (1,000,000 ohms) are used. For example 3,300 ohms equals 3.3 kilo ohms or just 3.3 k and 1,500,000 ohms equals 1.5 mega ohms or 1.5 mega. Color "bands" are used to indicate the resistance value with each color signifying a number and these color bands are grouped closer to one end of the resistor than the other. Fig. 2.7.1a: Four Band resistor color code.
  • 23. ©Daffodil International University 12 As can be seen in the above 4 Band Resistor Color Codes chart, the first two color bands have values of brown = 1, red = 2, orange = 3 and so on. The third color band is the multiplier of the first 2 bands. Here, black is 1, brown is 10, red is 100 and so on. Putting this in other words, the value of the third band (the multiplier) is the number 10 raised to the power of the color code. For example, red in the third band is 10² or 100.This third band also has 2 new colors where gold = 0.1 and silver = 0.01. The 4th band is the resistor's tolerance and shows how precisely the resistor was manufactured. Gold = 5%, silver = 10% and no band whatsoever = 20%. Now that we know the values of each color, let's try calculating a few examples of resistance values. Looking at resistor 1, we see the colors red red green gold. The Color Codes chart "translates" this into 2 2 and 100,000 which equals 22 ×100,000 or 2,200,000 ohms and don't forget the gold 4th band which indicates a 5% tolerance. Resistor 2 has the colors orange orange yellow silver which "translates" into 3 3 ×10,000 or 330,000 ohms and a tolerance of 10%. Resistor 3 has the colors yellow violet silver meaning 4 7 ×.01 or .47 ohms and no fourth band indicates a 20% tolerance.
  • 24. ©Daffodil International University 13 2.6.1b FIVE BAND RESISTORS Fig. 2.7.1b: Five and six band resistor color code. Use the 5 Band Chart to solve these next problems. For resistor 4, we see the first 3 bands are violet, green and red which "translate" into 7, 5 and 2. Looking at the fourth band (the multiplier); we see it is brown and has a value of 10. So, the resistance value is 7 5 2 × 10 which equals 7,520 ohms or 7.52 K ohms. Band 5 is red which indicates a 2 per cent tolerance and a brown sixth band means that the temperature coefficient is 100 parts per million (ppm). Examining resistor 5, the first 3 bands are brown, black and blue and the fourth band (the multiplier) is green. So, these colors convert into 1 0 6 × 100,000 which calculates to 10,600,000 ohms or 10.6 Meg ohms. The brown 5th band and the red 6th band mean that the resistor has a 1% tolerance and a 50 ppm temperature coefficient.
  • 25. ©Daffodil International University 14 If you've read these instructions, you probably have a good understanding of determining a resistor's value from its colors. Then again, there's always the calculator which makes things much easier to solve. 2.7 CAPACITOR A capacitor (originally known as a condenser) is a passive two-terminal electrical component used to store energy electrically in an electric field. The forms of practical capacitors vary widely, but all contain at least two electrical conductors (plates) separated by a dielectric (i.e., insulator). The conductors can be thin films of metal, aluminum foil or disks, etc. The 'non-conducting' dielectric acts to increase the capacitor's charge capacity. A dielectric can be glass, ceramic, plastic film, air, paper, mica, etc. Capacitors are widely used as parts of electrical circuits in many common electrical devices. Unlike a resistor, a capacitor does not dissipate energy. Instead, a capacitor stores energy in the form of an electrostatic field between its plates. Fig. 2.8: Electrolytic Capacitor Fig. 2.8.1: Ceramic Capacitor When there is a potential difference across the conductors (e.g., when a capacitor is attached across a battery), an electric field develops across the dielectric, causing positive charge (+Q) to collect on one plate and negative charge (-Q) to collect on the other plate. If a battery has been attached to a capacitor for a sufficient amount of time, no current can flow through the capacitor.
  • 26. ©Daffodil International University 15 However, if an accelerating or alternating voltage is applied across the leads of the capacitor, a displacement current can flow. An ideal capacitor is characterized by a single constant value for its capacitance. Capacitance is expressed as the ratio of the electric charge (Q) on each conductor to the potential difference (V) between them. The capacitance is greater when there is a narrower separation between conductors and when the conductors have a larger surface area. In practice, the dielectric between the plates passes a small amount of leakage current and also has an electric field strength limit, known as the breakdown voltage. The conductors and leads introduce an under sired inductance and resistance. Capacitors which have a value of one Farad or more tend to have a solid dielectric and as “One Farad” is such a large unit to use, prefixes are used instead in electronic formulas with capacitor values given in micro-Farads (μF), nano-Farads (nF) and the pico-Farads (pF). For example: Sub-units of the Farad microfarad, (µF) = F = 1×10-6 F nanofarad, (nF) = F = 1×10-9 F picofarad, (pF) = F = 1×10-12 F 2.8 DIODE A diode is a simple electrical device that allows the flow of current only in one direction. So it can be said to act somewhat like a switch. A specific arrangement of diodes can convert AC to pulsating DC, hence it is sometimes also called as a rectifier. It is derived from "di-ode " which means a device having two electrodes. The symbol of a p-n junction diode is shown below, the arrowhead points in the direction of conventional current flow. The p-n junction is a basic building block in any semiconductor device. It is formed by joining a p type (instrinsic semiconductor doped with a trivalent impurity) and n type semiconductor (intrinsic semiconductor doped with a pentavalent impurity) together with a special fabrication technique
  • 27. ©Daffodil International University 16 such that a p-n junction is formed. Hence it is a device with two elements, the p-type forms anode and the n-type forms the cathode. These terminals are brought out to make the external connections. Fig. 2.9: DIODE. The n side will have large number of electrons and very few holes (due to thermal excitation) whereas the p side will have high concentration of holes and very few electrons. Due to this a process called diffusion takes place. In this process free electrons from the n side will diffuse (spread) into the p side and combine with holes present there, leaving a positive immobile (not moveable) ion in the n side. Hence few atoms on the p side are converted into negative ions. Similarly few atoms on the n-side will get converted to positive ions. Due to this large number of positive ions and negative ions will accumulate on the n-side and p-side respectively. This region so formed is called as depletion region. Due to the presence of these positive and negative ions a static electric field called as "barrier potential" is created across the p-n junction of the diode. It is called as "barrier potential" because it acts as a barrier and opposes the flow of positive and negative ions across the junction. 2.9 LIGHT EMITTING DIODE (LED) In LED electrical energy is converter in to optical energy. These are example of electro- luminescence, the process in which emission of photos takes place by the recombination of excess electrons and holes in a direct band gap semiconductor. The main advantages of using
  • 28. ©Daffodil International University 17 these are the low energy consumption, longer lifetime, strong build, smaller size etc. The LED images given below. Fig. 2.10: LED with symbol. 2.10 RELAY A relay is usually an electromechanical device that is actuated by an electrical current. The current flowing in one circuit causes the opening or closing of another circuit. Relays are like remote control switches and are used in many applications because of their relative simplicity, long life, and proven high reliability. Relays are used in a wide variety of applications throughout industry, such as in telephone exchanges, digital computers and automation systems. Highly sophisticated relays are utilized to protect electric power systems against trouble and power blackouts as well as to regulate and control the generation and distribution of power. In the home, relays are used in refrigerators, washing machines and dishwashers, and heating and air-conditioning controls. Although relays are generally associated with electrical circuitry, there are many other types, such as pneumatic and hydraulic. Input may be electrical and output directly mechanical, or vice versa.
  • 29. ©Daffodil International University 18 Fig. 2.11: Electromagnetic relay. Fig.2.11.1: Protection diode for relay. These active semiconductor devices use light instead of magnetism to actuate a switch. The light comes from an LED, or light emitting diode. All relays contain a sensing unit, the electric coil, which is powered by AC or DC current. When the applied current or voltage exceeds a threshold value, the coil activates the armature, which operates either to close the open contacts or to open the closed contacts. When a power is supplied to the coil, it generates a magnetic force that actuates the switch mechanism. The magnetic force is, in effect, relaying the action from one circuit to another. 2.11 CONNECTOR Connectors are used to join subsections of circuits together. Usually, a connector is used where it may be desirable to disconnect the subsections at some future time: power inputs, peripheral connections, or boards which may need to be replaced. There are different types of connectors, In this project we used few of them. 2.11a Pin Header Connector Pin header connectors comprise several different means of connection. Generally, one side is a series of pins which are soldered to a PCB, and they can either be at a right-angle to the PCB surface (usually called “straight”) or parallel to the board’s surface (confusingly referred to
  • 30. ©Daffodil International University 19 as “right-angle” pins). Such connectors come in a variety of pitches, and may have any number of individual rows of pins. Fig. 2.12.1: Single female pin header. Fig. 2.12.2: Double male pin header. The most commonly seen pin headers are .1" single or double row connectors. These come in male and female versions, and are the connectors used to connect PCB boards and shields together. 2.11b Temporary connector Screw Terminals In some cases, it may be desirable to be able to connect bare unterminated wire to a circuit. Screw terminals provide a good solution for this. They are also good for situations in which a connection should be capable of supporting multiple different connecting devices. Temporary connector figure shown in below. Fig. 2.12.3: Temporary connector. 2.12 ATMEGA8 MICROCONTROLLER A microcontroller (also microcomputer, MCU or µC) is a small computer on a single integrated circuit consisting internally of a relatively simple CPU, clock, timers, I/O ports, and
  • 31. ©Daffodil International University 20 memory. Microcontrollers are designed for small or dedicated applications. Microcontrollers are used in automatically controlled products and devices, such as automobile engine control systems, remote controls, office machines, appliances, power tools, and toys. The ATmega8A is a low-power CMOS 8-bit microcontroller based on the AVR RISC architecture. By executing powerful instructions in a single clock cycle, the ATmega8A achieves throughputs approaching 1 MIPS per MHz, allowing the system designer to optimize power consumption versus processing speed. It is a High-performance, Low-power AVR® 8-bit Microcontroller having Advanced RISC Architecture Fig. 2.13: ATMEGA8 Microcontroller. Having features like – 32 x 8 General Purpose Working Registers – Up to 16 MIPS Throughput at 16 MHz – 8K Bytes of In-System Self-programmable Flash program memory – 512 Bytes EEPROM – 1K Byte Internal SRAM
  • 32. ©Daffodil International University 21 – Write/Erase Cycles: 10,000 Flash/100,000 EEPROM – Data retention: 20 years at 85°C/100 years at 25°C – Programming Lock for Software Security – Two 8-bit Timer/Counters with Separate Prescaler, one Compare Mode – One 16-bit Timer/Counter with Separate Prescaler, Compare Mode, and Capture – Real Time Counter with Separate Oscillator – Three PWM Channels – Programmable Serial USART – Master/Slave SPI Serial Interface – Programmable Watchdog Timer with Separate On-chip Oscillator – On-chip Analog Comparator - Power-on Reset and Programmable Brown-out Detection - Internal Calibrated RC Oscillator - External and Internal Interrupt Sources - Five Sleep Modes: Idle, ADC Noise Reduction, Power-save, Power-down, and - 23 Programmable I/O Lines Operating Voltages 2.7 - 5.5V for ATmega8A
  • 33. ©Daffodil International University 22 2.12.1 Pin description of ATMEGA8 microcontroller VCC: Digital supply voltage. Magnitude of the voltage range between 4.5V to 5.5V for the ATmega8. GND: Ground reference digital voltage. Fig. 2.13.1: Pin diagram of ATMEGA8 microcontroller. PORTB (PB7:PB0): PORTB is a port i/o two way (bidirectional) 8-bit with internal pull-up resistor can be selected. This port output buffers have symmetrical characteristics when used as an input, the pull-pin low externally will emit a current if the pull-up resistor is activated it. PORTB pins will be in the condition of the tri-state when RESET is active, although the clock is not running.
  • 34. ©Daffodil International University 23 Table 1: PORTB pin description. PORTC (PC5:PC0): PORTC is a port I / O two-way (bidirectional) 7-bit with internal pull- up resistor can be selected. This port output buffers have symmetrical characteristics when used as a source or sink. When used as an input, the pull-pin low externally will emit a current if the pull-up resistor is activated it. PORTC pins will be in the condition of the tri-state when RESET is active, although the clock is not running. Table 2: PORTC pin description.
  • 35. ©Daffodil International University 24 PC6/RESET: If the RSTDISBL Fuse is programmed, PC6 is used as an I/O pin. Note that the electrical characteristics of PC6 differ from those of the other pins of Port C. If the RSTDISBL Fuse is not programmed, PC6 is used as a Reset input. A low level on this pin for longer than the minimum pulse length will generate a Reset, even if the clock is not running. Port D (PD7:PD0): Port D is an 8-bit bi-directional I/O port with internal pull-up resistors (selected for each bit). The Port D output buffers have symmetrical drive characteristics with both high sink and source capability. As inputs, Port D pins that are externally pulled low will source current if the pull-up resistors are activated. Table 3: PORTD pin description. RESET: Reset input. A low level on this pin for longer than the minimum pulse length will generate a reset, even if the clock is not running. AVCC: AVCC is the supply voltage pin for the A/D Converter, Port C (3:0), and ADC (7:6). It should be externally connected to VCC, even if the ADC is not used. If the ADC is used, it should be connected to VCC through a low-pass filter. Note that Port C (5:4) use digital supply voltage, VCC. AREF: AREF is the analog reference pin for the A/D Converter.
  • 36. ©Daffodil International University 25 CHAPTER-3 DESCRIPTION OF CIRCUIT DIAGRAM 3.1 AUTOMATIC LIGHT CONTROL CIRCUIT DESIGN: The circuit diagram of this project is given below which is draw by Proteus ISP Professional software. Fig. 3.1: Circuit diagram of automatic light system. This is the total circuit diagram sketching. We will define/ discuss this in three part:
  • 37. ©Daffodil International University 26 3.2 Part 1: Power input circuit. 3.3 Part 2: Operation in LDR and Microcontroller. 3.4 Part 3: Output of relay. In this section we came to know that how the parts connected and how they work. The three most important sections will describe through this process. In this circuit diagram we used different electronics parts. They are following: Resistors, Transistor, Capacitors, voltage regulator, LDR, LED, power supply, microcontroller and relay. 3.2 Part-1(Power input circuit): In the beginning of making this project we collect our entire component as we make a list. In this power supply section 12V DC adapter connected with J2. A diode D1 is connected in series with IC 7805 voltage regulator. Capacitor C2 (100µF) connected with input terminal of IC 7805 and C3 (10µF) connected with output terminal. C4 (0.1µF) capacitor is connected parallel with C2 and C3. Two pin header male connector embedded parallel of this circuit. Although there is a diode D3 connected parallel with this power circuit. Fig. 3.2: Power supply circuit Here D1 diode is used for give reverse polarity protection to circuit. R3 resistor 10K connected in series with a LED D2 which indicate the power supply. Diode D3 is used for short circuit
  • 38. ©Daffodil International University 27 protection to microcontroller. The regulated 5V DC supply connected with LDR and ATmega8 microcontroller. 3.3 Part-2(Operation in LDR and Microcontroller): In this part we connected a LDR in series with R1 (10KΩ) and R2 (100Ω) resistor. Capacitor C5 (10µF) connected in parallel with LDR. Fig. 3.3: Operation in LDR. When light falls on LDR then its resistivity decrease, and when darkness around the LDR resistivity increases. The resistivity value is input in ADC5 (28 no. pin) to ATmega8 microcontroller. The output comes from PB1 (15 no. pin) port of microcontroller. PB0 and PB1 (1 and 2 no pin) port is connected with a single female pin header connector which can debug this circuit. AVCC and AREF port (20 and 21 no. pin) connected with a capacitor C1(100nF) in series. Pin 7 and 8 connected for VCC and GND connection of ATmega8 microcontroller.
  • 39. ©Daffodil International University 28 Fig. 3.3.1: Operation in ATmega8 Microcontroller. ATmega8 microcontroller give signal to transistor. It has programmed by AVR programmer. The program is given below: Chip type : ATmega8L Program type : Application AVR Core Clock frequency: 8.000000 MHz Memory model : Small External RAM size : 0 Data Stack size : 256 *****************************************************/
  • 40. ©Daffodil International University 29 #include <mega8.h> #include <delay.h> // Standard Input/Output functions #include <stdio.h> ////////////////////////////////// //Programmer Setting #define relay PORTB.1 #define ON 1 #define OFF 0 ///////////////////////////////// //////////////////////////////// //User Setting #define Dark 800 #define Light 600 ///////////////////////////////// #define ADC_VREF_TYPE 0x00 // Read the AD conversion result unsigned int read_adc(unsigned char adc_input) {
  • 41. ©Daffodil International University 30 ADMUX=adc_input | (ADC_VREF_TYPE & 0xff); // Delay needed for the stabilization of the ADC input voltage delay_us(10); // Start the AD conversion ADCSRA|=0x40; // Wait for the AD conversion to complete while ((ADCSRA & 0x10)==0); ADCSRA|=0x10; return ADCW; } // Declare your global variables here unsigned int adc=0; void main(void) { // Declare your local variables here // Input/Output Ports initialization // Port B initialization // Func7=In Func6=In Func5=In Func4=In Func3=In Func2=In Func1=In Func0=Out // State7=T State6=T State5=T State4=T State3=T State2=T State1=T State0=0
  • 42. ©Daffodil International University 31 PORTB=0x00; DDRB=0x02; // USART initialization // Communication Parameters: 8 Data, 1 Stop, No Parity // USART Receiver: On // USART Transmitter: On // USART Mode: Asynchronous // USART Baud Rate: 9600 UCSRA=0x00; UCSRB=0x18; UCSRC=0x86; UBRRH=0x00; UBRRL=0x33; // ADC initialization // ADC Clock frequency: 62.500 kHz // ADC Voltage Reference: AREF pin ADMUX=ADC_VREF_TYPE & 0xff; ADCSRA=0x87; printf("LDR Based AC Light Control Projectrn");
  • 43. ©Daffodil International University 32 printf("Designed By farzana muhaiminrn"); delay_ms(1000); while (1) { // Place your code here adc=read_adc(5); delay_ms(100); printf("LDR=%drn",adc); delay_ms(500); if(adc>Dark)// if darkness { delay_ms(10); relay=ON; } if(adc<Light)// if day light { delay_ms(10); relay=OFF;
  • 44. ©Daffodil International University 33 This program install in microcontroller. If the light resistivity around 600 then it gives signal to relay OFF and resistivity 800 then it gives signal to relay ON. 3.4 Part-3(Output of relay): In this part 12V DC power supply connected with a relay. A transistor is connected with a output of microcontroller. Transistor is connected in series with a resistor R36 (4.7KΩ). D9 is connected parallel with relay coil. Temporary Connector J30 is connected with relay contacts. Fig. 3.4: Output of relay. As the current flows through the coil a self induced magnetic field is generated around it. When the current in the coil is turned “OFF”, a large back e.m.f (electromotive force) voltage is produced as the magnetic flux collapses within the coil. This induced reverse voltage value may be very high in comparison to the switching voltage, and may damage any semiconductor device
  • 45. ©Daffodil International University 34 such as a transistor, FET or micro-controller used to operate the relay coil. One way of preventing damage to the transistor or any switching semiconductor device, is to connect a reverse biased diode across the relay coil. When the current flowing through the coil is switched “OFF”, an induced back emf is generated as the magnetic flux collapses in the coil. This reverse voltage forward biases the diode which conducts and dissipates the stored energy preventing any damage to the semiconductor transistor. When used in this type of application the diode is generally known as a Flywheel Diode, Free- wheeling Diode and even Fly-back Diode, but they all mean the same thing. Fig. 3.4.1: When relay NO (ON STATE). Fig. 3.4.2: When relay NC (OFF STATE). A LED D24 and resistor R43 (470Ω) connected in series with 12V dc power supply and D24 shows status of relay ON and OFF condition. CHAPTER-4 PRODUCT COST AND RESULTS
  • 46. ©Daffodil International University 35 4.1 PARTS LIST The name of parts used in this project are given below: NAME OF PARTS QUALITY QUANTITY Capacitors 100nF 2 C1, C4 C2 100µF 1 C3, C5 10µF 2 Resistors 10KΩ 2 R1, R3 R2 100Ω 1 R36 4.7KΩ 1 R43 470Ω 1 Diodes 1N4007 3 D1,D3,D4 LED(D2, D24) LED-GREEN 2 LDR TORCH-LDR 1 Connectors CONN-SIL2 2 J1, J4 J2 TBLOCK M-2 1 J3 CONN-SIL5 1 J30 TBLOCK I3 1 Transistor PN2222 1 Voltage regulator (U2) IC 7805 1 Microcontroller (U1) ATmega8 1 Relay OMIH-SH-124D 1 4.2 PRODUCT COST
  • 47. ©Daffodil International University 36 The total cost of this project is given below: PARTS AND MATERIALS ITEM COST (in BDT) Capacitors 10Tk Resistors 10Tk LDR 20Tk Diodes 10Tk LED 8Tk Transistor 10Tk ATmega8 microcontroller 150Tk Voltage regulator 20Tk Connectors 35Tk Relay 20Tk Plug 20Tk 12V DC adaptor 100Tk Lamp with holder and switch 240Tk PCB design 200Tk TOTAL COST 853TK. 4.3 ADVANTAGES AND DISADVANTAGES 4.3.1 Advantages:  LDRs are sensitive, inexpensive and readily available devices. They have good power and voltage handling capabilities, similar to those of a conventional resistor.  They are small enough to fit into virtually any electronic device and used all around the world as a basis component in many electrical systems.
  • 48. ©Daffodil International University 37 4.3.2 Disadvantages:  It is sensitive to ambient light and require careful shielding.  Can be more complicated to align detector pairs. 4.4 AREA OF APPLICATIONS  It can be used in some clocks, alarms, and other electronic devices that are dependent on sunlight.  We can used it outside of house, corridors or industry area, which helps to save power.  It can be used as a street light.  In sea off-shore side we can use it as a dangerous sign
  • 49. ©Daffodil International University 38 4.5 RESULTS AND DISCUSSIONS The project aims were to reduce the side effects of the current lighting system, and find a solution to save power. In this project the first thing to do, is to prepare the inputs and outputs of the system to control the lights. The project shown in Fig.4 has been implemented and works as expected and will prove to be very useful. Fig. 4: Project on automatic light system. FUTURE SCOPE The above project we can develop solar street light system with Automatic street light controller. The system can be powered from a battery, which can be charged during day time by harvesting the solar energy through a solar cell. The solar energy harvested from sunlight can be stored, inverted from DC voltages to AC voltage using sun tie converter.
  • 50. ©Daffodil International University 39 The AC voltage can be stepped down rectified and using the circuit. The above mentioned strategy will enable us to harvest solar energy in an effective way for the operation of the circuit and for powering the street light also. CONCLUSION This paper elaborates the design and construction of automatic light control system circuit. Circuit works properly to turn lamp ON/OFF. LDR sensor is the main conditions in working the circuit. If the conditions have been satisfied the circuit will do the desired work according to specific program. Each sensor controls the turning ON or OFF the lighting column. The lights has been successfully controlled by microcontroller. With commands from the controller the lights will be ON in the places of the movement when it's dark. Finally this control circuit can be used in various purposes.
  • 51. ©Daffodil International University 40 REFERENCES [1] M. A. Wazed, N. Nafis, M. T. Islam and A. S. M. Sayem, Design and Fabrication of Automatic Street Light Control System, Engineering e-Transaction, Vol. 5, No. 1, June 2010, pp 27-34. [2] K.Y. Rajput, G. Khatav, M. Pujari, P. Yadav, Intelligent Street Lighting System Using Gsm, International Journal of Engineering Science Invention, Vol2, Issue 3, March 2013, PP. 60- 69. [3] D. A. Devi and A. Kumar, Design and Implementation of CPLD based Solar Power Saving System for Street Lights and Automatic Traffic Controller, International Journal of Scientific and Research Publications, Vol. 2, Issue11, November 2012. [4] K. S. Sudhakar, A. A. Anil, K. C. Ashok and S. S. Bhaskar, Automatic Street Light Control System, International Journal of Emerging Technology and Advanced Engineering, Vol. 3, May 2013, PP. 188-189. [5] Programming and Customizing The AVR Microcontroller by Dhananjay V. Gadre [6] Programming 16-bit Microcontrollers in C by Lucio Di Jasio [7] Power Electronics(circuits, devices and applications) 3rd edition By M H Rashid [8] Electronic Devices and Circuit Theory - Robert Boylestad & Louis Nashelsky - 7th Edition [9] An Introduction to programming an Atmega microcontroller By Benjamin Reh [10] W. Bolton. Instrumentation and Control Systems, Elsevier Science & Technology Books, August 2004. Internet sources: http://www.electronics-tutorials.ws/io/io_5.html http://www.kanda.com/blog/microcontrollers/avr-microcontrollers/avr-microcontroller/ http://www.circuitstoday.com/category/voltage-regulators