Sunteți pe pagina 1din 52

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

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.

~i~

DEDICATION

To the person who supported us through the hole life


Thanks to our Parents and rest of our family

~ ii ~

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.

~ iii ~

CONTENTS

CONTENT NAME

PAGE

Acknowledgement

Dedication

ii

Abstract

iii

1. CHAPTER-1

INTRODUCTION

1.1Objective

1.2 Project Block Diagram

1.3 Project Block Diagram Description

2. CHAPTER-2

HARDWARE IMPLEMENTATION

2.1 Description of Components

2.2 Light Dependent Resistor

2.2.1Recovery Rate

2.3 Power Supply

2.4 Voltage Regulator

2.5 Transistor

2.6 Resistor

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

Fig 2.1

LDR

Fig 2.1.1

Symbol of LDR

Fig 2.2

Practical LDR

Fig 2.3

12V DC adapter

Fig: 2.4

IC 7805 voltage regulator

Fig: 2.5

NPN transistor & symbol of NPN

Fig: 2.6

I-V characteristics curve of NPN transistor

Fig: 2.7

Resistor

Fig: 2.7.1

Symbol of Resistor

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:

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

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 cant be replaced. Once we use them up theyre 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

1.2 PROJECT BLOCK DIAGRAM


The system basically consists of a LDR, Power supply, Transistor, Relays and
Microcontroller.

Regulated power supply

LDR

TRANSISTOR

RELAY

MICROCONTROLLER
LAMP

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.

Daffodil International University

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

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

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

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

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

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

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, V is 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.

Daffodil International University

Fig. 2.7.1: Symbol of resistor.

Fig. 2.7FFFF

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

10

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

11

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

12

2.6.1b FIVE BAND RESISTORS

Fig. 2.7.1b: Five and six band resistor color code.

Use

the

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

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

13

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

14

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 = 110-6 F

nanofarad, (nF) =

F = 110-9 F

picofarad, (pF) =

F = 110-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

15

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 electroluminescence, 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

16

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

17

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 boards surface (confusingly referred to

Daffodil International University

18

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

19

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

20

Write/Erase Cycles: 10,000 Flash/100,000 EEPROM


Data retention: 20 years at 85C/100 years at 25C
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

21

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

22

Table 1: PORTB pin description.

PORTC (PC5:PC0): PORTC is a port I / O two-way (bidirectional) 7-bit with internal pullup 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

23

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

24

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

25

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 (100F) connected with input terminal of IC 7805 and
C3 (10F) connected with output terminal. C4 (0.1F) 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

26

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 (10F) 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

27

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
External RAM size
Data Stack size

: Small
:0
: 256

*****************************************************/

Daffodil International University

28

#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

29

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

30

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 Project\r\n");
Daffodil International University

31

printf("Designed By farzana muhaimin\r\n");


delay_ms(1000);
while (1)
{
// Place your code here
adc=read_adc(5);
delay_ms(100);
printf("LDR=%d\r\n",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

32

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

33

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, Freewheeling 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

34

4.1 PARTS LIST


The name of parts used in this project are given below:
NAME OF PARTS

QUALITY

QUANTITY

Capacitors
C1, C4

100nF

C2

100F

C3, C5

10F

Resistors
R1, R3

10K

R2

100

R36

4.7K

R43

470

1N4007

Diodes
D1,D3,D4
LED(D2, D24)
LDR

LED-GREEN

TORCH-LDR

J1, J4

CONN-SIL2

J2

TBLOCK M-2

J3

CONN-SIL5

J30

TBLOCK I3

Transistor

PN2222

Voltage regulator (U2)

IC 7805

Microcontroller (U1)

ATmega8

Relay

OMIH-SH-124D

Connectors

4.2 PRODUCT COST

Daffodil International University

35

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
ATmega8 microcontroller

10Tk
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

36

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

37

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

38

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

39

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

40

Daffodil International University

41

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