8/22/2019 Mpi Final Report v Final
1/16
Project Report
Automatic Street Light Switching
using PIC 16F877A, Keypad, LCD and LDR.
Group Members:
Asim Aslam BTE-FA10-085
Farooq Ather BTE-FA10-029
COMSATS INSTITUTE OF INFORMATION AND TECHNOLOGY, Lahore.
8/22/2019 Mpi Final Report v Final
2/16
- 2 -
Table of contents
Section Paritculars Page
1 Introduction 3
1.1 Block Diagram 4
2 Interfacing 5
2.1 LCD 5
2.2 Keypad 5
2.3 Light Dependent Resistor 6
2.4 Fixed resistor 6
2.5 Crystal oscillator 7
2.6 Light Emitting Diode 7
3 Peripherals 8
3.1Microcontroller
8
3.2 Core architecture of PIC 16F877A 9
3.3 ADC 9
4 Software 9
4.1 Proteus 9
4.2Mikro C:
10
5 Packaging 10
6 Summary 11
7 References 12
7.1 Interface Schematic 13
7.2 Software Flow Chart 14
7.3 Data Sheets of LDR,PIC16F877A, 15
8/22/2019 Mpi Final Report v Final
3/16
- 3 -
1. Introduction:
This project is mainly used to switch on/off the street lights automatically instead of doing
manual by using LDR. The main consideration in the present field technologies are
Automation, Power consumption and cost effectiveness. Automation is intended to reduce
man power with the help of intelligent systems. Power saving is the main consideration forever
as the source of the power(Thermal, Hydro etc.,)are getting diminished due to various reasons.
The main aim of the project is Automatic street light control system with LDR, this is the
sensor to sense the illumination intensity. It can operate on five different levels of illumination
intensity. LCD is used to show the current operating mode and to choose the option from
menu. For security purpose the menu is protected through a password. Only authorized person
can change the operating mode of the device. It can save the power by switching the street light
on/off immediately on current illumination intensity level. We want to save power
automatically instead of doing manual. So its easy to make cost effectiveness. This saved
power can be used in some other cases. So in villages, towns etc we can design intelligent
systems for the usage of street lights.
We worked a lot on this project and we learned a number of lessons about practical filed work
including purchasing of components, vendors of electronic devices. Farooq Ather worked a lot
on programming end as well as purchasing the components from market. Asim Aslam did a bit
programming but complete PCB designing on both software and hardware, soldering and
troubleshooting all the components. We learned some basic techniques of trouble shooting.
One of them is incremental checking of all components to find the faulty device. We team
members remained in contact through out the complete duration of project making.
8/22/2019 Mpi Final Report v Final
4/16
- 4 -
1.1. Block Diagram:
PIC 16F877A
Micro Controller
16*2 LCD
Keypad
Street
Lights
LDR
8/22/2019 Mpi Final Report v Final
5/16
- 5 -
2. INTERFACING:
2.1LCD:
Stands for "Liquid Crystal Display. It is used in this project to show the current operating level
of the device.
LCD modules can be split into two groups: those that have built-in controller and driver chips, andthose that have only driver chips. LCD displays that do not have controllers are typically used
with powerful hardware, such as a laptop computer, where a video controller is available to
generate the complex drive signals necessary to run the display. Most color and large (greaterthan 320x240) monochrome displays are of this type.
The category of display modules that have built-in controllers can be split again into character
LCD modules and graphic LCD modules. In this project LCD shows the current mode of deviceand it helps to change the current level with the help of keypad.
2.2 Keypad:
In this project, Keypad is used to input the operating level of intensity of the device. The
keypads circuit board consists of 12 switches in normally open condition. When any button ispressed the switch gets ON. Through defined row and column position algorithm the micro
controller fetches the value of pressed one switch. We used the keypad for selection of certain
items from the program menu in runtime and for password entry to authorize the right user of
the device.
8/22/2019 Mpi Final Report v Final
6/16
- 6 -
2.4 LIGHT DEPENDENT RESISTOR:
Light Dependent Resistor changes its resistance value due to incident light illumination level. As
illumination increases LDR decreases its resistance and vice versa.. It means that the resistance of
semiconductors decreases with increase in the light intensity. Therefore, these semiconductors are
called photoconductive cells or photo resistors or Light Dependent Resistors (LDR), since incident
light effectively varies their resistance. In bright light the resistance of the cell can be as low as 80
ohm. When the cell is kept in darkness its resistance is called dark resistance. At 50 LUX (darkness)
the resistance increases to over 1M ohm. Output voltages (Vo) are provided on Ao pin of the
microcontroller. In full darkness there are 5v on output Vo whereas in full sunny day the voltage level
reduces to 1v..
2.5 Fixed Resistence:
A resistor is apassivetwo-terminalelectrical component that implements electrical resistance as a
circuit element.The current through a resistor is in direct proportion to the voltage across theresistor'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 ofvolts, andR is the resistance of the conductor in units of
ohms.
http://en.wikipedia.org/wiki/Ohm%27s_lawhttp://en.wikipedia.org/wiki/Ohmhttp://en.wikipedia.org/wiki/Ohmhttp://en.wikipedia.org/wiki/Voltshttp://en.wikipedia.org/wiki/Ampereshttp://en.wikipedia.org/wiki/Electrical_conductorhttp://en.wikipedia.org/wiki/Ohm%27s_lawhttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Direct_proportionhttp://en.wikipedia.org/wiki/Electric_currenthttp://en.wikipedia.org/wiki/Electrical_resistancehttp://en.wikipedia.org/wiki/Electronic_componenthttp://en.wikipedia.org/wiki/Terminal_(electronicshttp://en.wikipedia.org/wiki/Passivity_(engineering8/22/2019 Mpi Final Report v Final
7/16
- 7 -
2.6 Crystal Oscillator:
A crystal oscillator is an electronic oscillator circuit that uses the mechanical resonance of a
vibrating crystal ofpiezoelectric material to create an electrical signal with a very precise frequency.
When a crystal ofquartz is properly cut and mounted, it can be made to distort in an electric field by
applying a voltage to an electrode near or on the crystal. This property is known aspiezoelectricity.
When the field is removed, the quartz will generate an electric field as it returns to its previous
shape, and this can generate a voltage. The result is that a quartz crystal behaves like a circuitcomposed of an inductor, capacitor and resistor, with a precise resonant frequency. The resonant
frequency depends on size, shape, elasticity, and the speed of sound in the material. High-frequency
crystals are typically cut in the shape of a simple, rectangular plate. Low-frequency crystals, such as
those used in digital watches, are typically cut in the shape of a tuning fork. For applications not
needing very precise timing, a low-cost ceramic resonatoris often used in place of a quartz crystal.
2.7 LED:
A light-emitting diode (LED) is a semiconductor light source. LEDs are used as indicator lamps in
many devices and are increasingly used for other lighting. Appearing as practical electroniccomponents in 1962,early LEDs emitted low-intensity red light, but modern versions are available
across the visible, ultraviolet, and infrared wavelengths, with very high brightness.
http://en.wikipedia.org/wiki/Electronic_oscillatorhttp://en.wikipedia.org/wiki/Resonancehttp://en.wikipedia.org/wiki/Crystalhttp://en.wikipedia.org/wiki/Piezoelectricityhttp://en.wikipedia.org/wiki/Frequencyhttp://en.wikipedia.org/wiki/Quartzhttp://en.wikipedia.org/wiki/Electric_fieldhttp://en.wikipedia.org/wiki/Elasticity_(physicshttp://en.wikipedia.org/wiki/Speed_of_soundhttp://en.wikipedia.org/wiki/Tuning_forkhttp://en.wikipedia.org/wiki/Ceramic_resonatorhttp://en.wikipedia.org/wiki/Ceramic_resonatorhttp://en.wikipedia.org/wiki/Tuning_forkhttp://en.wikipedia.org/wiki/Speed_of_soundhttp://en.wikipedia.org/wiki/Elasticity_(physicshttp://en.wikipedia.org/wiki/Resistorhttp://en.wikipedia.org/wiki/Capacitorhttp://en.wikipedia.org/wiki/Inductorhttp://en.wikipedia.org/wiki/Piezoelectricityhttp://en.wikipedia.org/wiki/Electrodehttp://en.wikipedia.org/wiki/Voltagehttp://en.wikipedia.org/wiki/Electric_fieldhttp://en.wikipedia.org/wiki/Quartzhttp://en.wikipedia.org/wiki/Frequencyhttp://en.wikipedia.org/wiki/Piezoelectricityhttp://en.wikipedia.org/wiki/Crystalhttp://en.wikipedia.org/wiki/Resonancehttp://en.wikipedia.org/wiki/Electronic_oscillator8/22/2019 Mpi Final Report v Final
8/16
- 8 -
3. Peripherals
3.1 PIC Microcontroller:
PIC standsfor Peripheral Interface Controller. This powerful (200 nanosecond instruction execution)
easy-to-program (only 35 single word instructions) CMOS FLASH-based 8-bit microcontroller
PIC16F877A packs Microchip's powerful PIC architecture into an 40-pin package and is upward
compatible. The PIC16F877A features 256 bytes of EEPROM data memory, self programming, an ICDComparators,
8 channels of 10-bit Analog-to-Digital (A/D) converter, 2 capture/compare/PWM functions, the synchronous
serial port can be configured as either 3-wire Serial Peripheral Interface (SPI) or the 2-wire Inter-Integrated
Circuit (IC) bus and a Universal Asynchronous Receiver Transmitter (USART). All of these features
make the PIC16F877A ideal for more advanced level A/D applications in automotive, industrial, appliances
and consumer applications. A PIC's instructions vary from about 35 instructions for the low-end PICs to over
80 instructions for the high-end PICs
PIC16F877A Memories
Flash (KB) 14
RAM (Bytes) 368
Data EEPROM (bytes) 256
PIC16F877A Features
Program Memory Type Flash
CPU Speed (MIPS) 5
Digital Communication
Peripherals
1-A/E/USART
1-
MSSP(SPI/I2C)
Capture/Compare/PWM
Peripherals2 CCP
Timers2x8-bit
1 x 16-bit
ADC 8 ch, 10-bit
Comparators 2
Operating Voltage Range (V) 2 to 5.5
8/22/2019 Mpi Final Report v Final
9/16
- 9 -
3.2 Core architecture
The PIC architecture is characterized by its multiple attributes:
Separate code and data spaces A small number of fixed length instructions Most instructions are single cycle execution (2 clock cycles, or 4 clock cycles in 8-bit
models), with one delay cycle on branches and skips
One accumulator(W0), the use of which (as source operand) is implied (i.e. is not encoded inthe opcode)
All RAM locations function as registers as both source and/or destination of math and otherfunctions
A hardware stack for storing return addresses A small amount of addressable data space (32, 128, or 256 bytes, depending on the family),
extended through banking
Data space mapped CPU, port, and peripheral registers ALU status flags are mapped into the data space
3.3ADC:
It stands for Analogue to Digital Converter. PIC 16f877a has two 10 pin ADC in it. We used this
ADC to convert the analogue values from LDR to digital values for comparing with user input value.
We used port A as analogue input. We dont take the digital value on output. We compared the
converted values with user input values while keeping both of them in some registers. We have
configured ADCON0 register to use built in register.
4. Software:
We used Mikro c as a compiler for c program and Proteus for simulation of microcontroller, LCD,
keypad and LEDS.
4.1 Proteus
Proteus is software formicroprocessor simulation, schematic capture, andprinted circuit board (PCB) design.
It is developed by Lab center Electronics.
ISIS Schematic Capture - a tool for entering designs. PROSPICE Mixed mode SPICE simulation -
industry standard SPICE3F5 simulator combined with a digital simulator. ARES PCB Layout - PCB
design system with automatic component placer, rip-up and retry auto-router and interactive design rule
http://en.wikipedia.org/w/index.php?title=Labcenter_Electronics&action=edit&redlink=1http://en.wikipedia.org/w/index.php?title=Labcenter_Electronics&action=edit&redlink=1http://en.wikipedia.org/wiki/Printed_circuit_boardhttp://en.wikipedia.org/wiki/Microprocessorhttp://en.wikipedia.org/wiki/Opcodehttp://en.wikipedia.org/wiki/Accumulator_(computing8/22/2019 Mpi Final Report v Final
10/16
- 10 -
checking. VSM - Virtual System Modeling lets co simulate embedded software for popular micro-
controllers alongside hardware design. System Benefits Integrated package with common user
interface and fully context sensitive help.
4.2 Mikro C:
Mikro C is a development tool which is made by Mikroelektronika. Mikroelektronika was
founded in 1997. by Neboja Mati, Serbian entrepreneur, owner and General Manager. The
company's slogan"making it simple"depicts efforts to make products easy-to-use and suitable
for beginners. Company's first development system EPIC1, initially constructed for
PIC16F84A microcontroller today is succeeded by 7th generation system Easy PIC v7, which
was symbolically launched on October 7, 2011. Its 6th generation system EasyPIC6 is widely
known in PIC development community. Mikroelektronika's products grew to be internationally
recognized, and now it has distributors in over 38 countries across the globe, according to
company's official distributors list. As of August 2011, company announced Mouser
Electronicsas its first world-wide distributor. Mikroelektronika is an official consultant on PIC
microcontrollers and third party partner ofMicrochip Technology.
5. Packaging:
We did not directly solder the terminals of any device (LCD, Microcontroller and Keypad) on printed
circuit board. We used the 40 pin base for microcontroller, 16 pin base for LCD and 7 pin base for
keypad. By using theses bases device can be plugged in or out easily without de-soldering of printed
circuit board. Then we used thermo pore sheet to make a foundation for the PCB. The PCB cannot be
short circuited from lower side if it is placed on any conducting material like steel or iron etc.
http://en.wikipedia.org/wiki/Entrepreneurhttp://en.wikipedia.org/wiki/General_Managerhttp://en.wikipedia.org/wiki/Sloganhttp://en.wikipedia.org/wiki/PIC16F84Ahttp://www.mikroe.com/easypic/http://www.mikroe.com/easypic/v6/http://www.mikroe.com/distributors/http://en.wikipedia.org/wiki/Microchip_Technologyhttp://en.wikipedia.org/wiki/Microchip_Technologyhttp://www.mikroe.com/distributors/http://www.mikroe.com/easypic/v6/http://www.mikroe.com/easypic/http://en.wikipedia.org/wiki/PIC16F84Ahttp://en.wikipedia.org/wiki/Sloganhttp://en.wikipedia.org/wiki/General_Managerhttp://en.wikipedia.org/wiki/Entrepreneur8/22/2019 Mpi Final Report v Final
11/16
- 11 -
5. Summary
The project is made to automate the street lights. It senses the ambient illumination level through LDR.
We have used LDR in series of a fixed resistor. As LDR gives analogue values on its output in the form
of volts. This value is then converted to digital value using the inner analogue to digital converter of the
microcontroller PIC16f877a. Keypad and LCD are used to take the input the operating level of the
device. It simultaneously shows the user keypad value as well as LDR value on screen during the
operation. In the device, five different levels are available (1 to 5) where 5 is the lowest level of
illumination. If user wants to switch on the street light before the sunset then he should select lower
level.
8/22/2019 Mpi Final Report v Final
12/16
- 12 -
6. References:
http://en.wikipedia.org/wiki/Crystal_oscillator
http://en.wikipedia.org/wiki/Led
http://technology-electronic.blogspot.com/2010/05/fixed-resistors.html
http://electronicsclub.info/vdivider.htm
http://en.wikipedia.org/wiki/PIC_microcontroller
http://en.wikipedia.org/wiki/Keypad
http://en.wikipedia.org/wiki/Crystal_oscillatorhttp://en.wikipedia.org/wiki/Ledhttp://technology-electronic.blogspot.com/2010/05/fixed-resistors.htmlhttp://electronicsclub.info/vdivider.htmhttp://en.wikipedia.org/wiki/PIC_microcontrollerhttp://en.wikipedia.org/wiki/PIC_microcontrollerhttp://en.wikipedia.org/wiki/Keypadhttp://en.wikipedia.org/wiki/Keypadhttp://en.wikipedia.org/wiki/PIC_microcontrollerhttp://electronicsclub.info/vdivider.htmhttp://technology-electronic.blogspot.com/2010/05/fixed-resistors.htmlhttp://en.wikipedia.org/wiki/Ledhttp://en.wikipedia.org/wiki/Crystal_oscillator8/22/2019 Mpi Final Report v Final
13/16
- 13 -
7.1 Interface Schematic:
8.
8/22/2019 Mpi Final Report v Final
14/16
- 14 -
7.2 Software Flow Chart:
Initialization
Takes value from
LDR
Takes user input
through keypad
Lights Off Lights ON
If user value
is less than
LDR value
8/22/2019 Mpi Final Report v Final
15/16
- 15 -
7. 3 Data Sheets of LDR,PIC16F877A
8/22/2019 Mpi Final Report v Final
16/16
- 16 -