Automatic control of street lights is designed to turn on and off street lights automatically. This project checks the amount of light. If the light is 80 percent available, it automatically turns off street lights. But, if the amount of light is less than 80 percent, this project will automatically turn on street lights. One can also adjust it according to their requirements.
A light sensor detects the intensity of light. The PIC16F877A microcontroller interfaces with the light sensor to sense the amount of light available. After analyzing the amount of light, the PIC16F877A microcontroller generates a control signal. The control signal turns on the transistor, which energizes the relay coil and turns on the street light. Only one lamp is used in this project for demonstration purposes, but you can use as many street lights as you want to control through this automatic street light control system.
Introduction
Automatic Street Lights Control with a Microcontroller is an innovative application of embedded systems technology aimed at enhancing energy efficiency and promoting sustainability in urban environments. This intelligent system utilizes a microcontroller, a compact and programmable integrated circuit, to autonomously manage the operation of street lights based on ambient light levels. The heart of the system lies in the utilization of a Light Dependent Resistor (LDR) to sense variations in natural light, allowing the microcontroller to dynamically control the illumination of street lights. This not only contributes to energy conservation by ensuring lights are active only when necessary but also offers the potential for significant cost savings and a reduced environmental footprint. This technological solution aligns with the growing emphasis on smart city initiatives, showcasing the application of embedded systems for more efficient and sustainable urban infrastructure.
Circuit Diagram Automatic Control of Street Light
The following are the main components of the automatic control of street lights:
Light sensor
The light sensor senses the amount of light. There are many light sensors available in the market, but the Light dependent resistor (LDR) is used as a light sensor because it is cheap in price, easily available in the market, and can be easily interfaced with a microcontroller to sense the intensity of light. The LDR has the property to change its resistance according to the intensity of light. If the light is high, the LDR will have low resistance, and if the light is low, the LDR will have high resistance. So, the microcontroller can easily read this resistance in the form of voltage, which can be back-converted into a proportional value of light using a formula available in the datasheet. I recommend you to look at the datasheet of the LDR.
Relay interfacing with microcontroller
As mentioned above, a microcontroller analyzes the intensity of light and generates a control signal, which in turn turns on or off the street light. We use an NPN transistor as a switch, and we use a resistor at the base of the transistor as a current-limiting resistor. We use a diode to avoid back EMF voltage, which can produce sparking across the relay.
The circuit diagram below illustrates the automatic control of street lights.
To check the working of this project and to understand the code, watch the following video:
Code
The code for this project is written in the MIKROC compiler and 8Mhz crystal is used in this project. If you do not know how to use MikroC for Pic, you can refer to these tutorials:
- How to Use “MikroC PRO for PIC” to Program PIC Microcontrollers
- Pic microcontroller programming in c using Mikroc Pro for PIC
//*************** microcontrollerslab.com ******************
//************** microcontrollerslabhub@gmail.com ***********
// Global variable to store light intensity
int light;
// Function to read LDR (Light Dependent Resistor)
void read_ldr()
{
unsigned int adc_value = 0;
// Read analog value from ADC channel 0
adc_value = ADC_Read(0);
// Calculate light intensity as a percentage
light = 100 - adc_value / 10.24;
// Switch off the light when light intensity is 80 percent or more
if (light >= 80)
{
PORTB.F1 = 0;
}
else
{
PORTB.F1 = 1;
}
}
// Main function
void main()
{
// Set PORTB as output
TRISB = 0X00;
// Initialize PORTB to 0
PORTB = 0X00;
// Initialize ADC
Adc_Init();
// Infinite loop
while (1)
{
// Read LDR and control light accordingly
read_ldr();
}
}
How Does Code Work?
This code is an implementation of an Automatic Street Lights Control system using a pic microcontroller. The program employs a global variable, ‘light,’ to store the calculated light intensity based on readings from a Light Dependent Resistor (LDR). The read_ldr() function is responsible for reading the analog value from ADC channel 0, converting it to a percentage to determine the light intensity, and subsequently controlling the street light. Specifically, if the light intensity surpasses 80 percent, the program switches off the street light by setting the corresponding bit (F1) in the PORTB register to 0; otherwise, it sets the bit to 1, keeping the light on. This conditional control ensures that the street lights operate efficiently, responding to the ambient light conditions.
In the main function, the code initializes the microcontroller by setting PORTB as an output for controlling the street lights, initializing PORTB to 0, and initializing the ADC module. The program then enters an infinite loop where it continuously reads the LDR values and adjusts the street lights accordingly. This implementation provides a basic yet functional example of an energy-efficient street lighting system that utilizes a microcontroller to intelligently respond to variations in ambient light levels.
Applications
This project has many applications. For example, you may be too lazy to manually turn on or off your street lights, and you may forget to do so daily. With this project, you can easily save electricity and, in turn, save money. In countries where load shedding is a big issue due to a shortfall in electricity and limited resources for its generation, this project can help to a certain extent. By automatically controlling street lights, we can save a maximum amount of energy, which is beneficial for your nation and also for you. It will reduce your electricity bill and, in turn, save you money.
You may also like to read:
- Digital DC Voltmeter using 7-Segment Display and Pic Microcontroller
- Alternating Current Measurement using Pic Microcontroller
- DC motor Speed control using pic microcontroller
- Rain Drop Sensor Module Interfacing with Pic Microcontroller– Rain Detector Circuit
- Infrared Flame Sensor Interfacing with Pic Microcontroller
- Automatic Temperature controller using pic microcontroller
Can you please upload the datasheet of LDR?
You can easily download it by searching on google
can u give the list of the components required
100-adc_value/1024
what’s the mening this formula
it is used to convert light intensity into percentage
please help me because appear error in this in mikroc
1/light = 100 -adc_value/10.24;
2/ I dont understand HOW WORK THIS EXPRESSION
adc_value=ADC_Read(0);
Hi
is not working…..
check video its working
Why didn’t you simulate it?? Because it doesn’t work ? Yeah it doesn’t work. Really.
check video its working.yOU must be making some mistake
thanks a lot dude it s worki,
What compiler did you use?
The code is not working .. its giving error in line “light = 100 – adc_value/10.24;”
these are the errors ..
6 402 ; expected, but ‘–’ found street light.c
6 424 ‘}’ expected ‘;’ found street light.c
11 371 Specifier needed street light.c
11 396 Invalid declarator expected'(‘ or identifier street light.c
14 371 Specifier needed street light.c
14 396 Invalid declarator expected'(‘ or identifier street light.c
16 393 ” Identifier redefined street light.c
16 300 Syntax Error: ‘(‘ expected, but ‘{‘ found street light.c
25 1503 Result is not defined in function: ” street light.c
0 102 Finished (with errors): 04 Jun 2015, 20:08:57 street light.mcppi
It is working. Check the video and which complier you are using ?
i have checked the video and i m doing the same thing as yours but when i try to build the program the error occurs. i m using Mikro C ..
Can you help me in solving the above issue.
I got the same errors when I complied the program.
Thanks in advance.
tell met the compiler name.
100-(adc_value/1023.0)*5=for read voltage
The issue is resolved .. thnx
one more thing to ask, it might look stupid but what is that component attached with resistor R3 .. i m not talking abt LDR the upper one ..
thnx in advance ….
That’s Great
It is 5 volt power supply
how did you resolved this issue.
please help.
how does it resolved? please help me , it is not working, it shows the errors that you have write?
How did you resolved the issue?
Please help me in solving it.
the code is not running the line:: adc_value=ADC_Read(0); i found Error here.
I need guidance in designing code for automatic street light system in AVR throgh ATMEGA16
Hi
Can you help me for project watt meter V/UHF.
Please mail me…
Thanks.
actually i want it to work with the IR sensors so as to conserve more energy so please provide help for this
1. how to connect IR sensor with this module.
2. n wat will b the changes in code.
I need help in designing a FPGA based automatic irrigation system
Great sir its very useful .
Sir please help me and give idea about the project on this topic.
need help in designing automatic room light contoll pic 16f877a need help with programing code
in mikro c
pls send complete code of above project
and also algorithm
i need a this project code for mplab xde
please upload again the video of automatic street light, it seems as it has removed.
please upload again the video so that we can have a look on it, and what mean adc_value=ADC_Read(0) ?
the programme is correct
do you hav code for 12MHz clock frequency ????
and using keil software ????
Can you please answer me a of a district in which LDR is used for save power.. It’s need because of my school project.. Some may question it.. please be fast to me..
BILAL, CAN WE WRIGHT SAME PROGRAM IN KAIL SOFTWARE ?
may i know what kind of diode is use in the circuit?
what model is that diode?
Plz the code isn’t workx, can some one help!!! Its compilx but not workx!
What’s the diff btw ADC, adc and Adc in the code? Will that not rep different things?
can i get this one in assembly language
sir ,please send me the circuit diagram with adding IR sensor and code for that circuit
May I know what is that component named L1 with 12v…
What is the type of Crystal oscillator used in the circuit diagram???
can you kindly explain the formula ? How did you have made this formula?
plz sir send me a complete c code of this project…..
hello
i m jyoti
can u give me a brief idea in this project
hi… Present I’m trying to get output in Proteus but it’s not coming… N may I know which part is troubling you?
can i use mikroc pro for pic v.6.0 or 8.2 version for executing above code.
Can you please upload the video again,it’s not available now
can you send me , the circuit diagram of “automatic street light based on vehicle moment” and its source code , im using microprocessor 8051…..!!!!
How to convert this into hex file
Bilal can i use this code for pic16f887
do you know how to programme this using mplab ide?
thank you in advance
What is the value of inductor in Henry ???
why it appear to be error when i’m done connected all the circuit?
please help me
how to measure LDR off time in pic program
can you give me complete code of this…
ask the blogger to give us answers
can you please tell me what is the advantage of using microcontroller other than LDR and relays
Can u plz send me the brief description of the working principle of the circuit ???????? and why 8Mhz crystal oscillator is used here?????????? plzz help me…its urgent
Sir the above ckt which you’ve given for ldr, doesn’t contain lcd for displaying output. so what if we want to put lcd there?? should we need right a program for lcd interfacing too???.
please suggest. it would be better if you give a program for this.
Will you please send me the code for ” auto intensity control of street lights using Atmega8 micro controller and which simulator I have to use?
sir can u please tell me the above circuit the resistor R1 (10 K) goes to where??? any supply?? thanks
can we make it for multiple street lights.?
Please send me the source code and circuit diagram for automatic street light using gsm and at89s52 microcontroller.
Please send me full code of this Project and this code working in keil..??
Comment Text*please help me to conduct thus project with title automatic street light controller
Hi am interested in this project can you please send me more details like the ratings of the components please
i need this code in keil uvision4
Can I get the full code for this please
Which software used for program
Need to manufacture street light controller, how can you help.E
Can you help me out of working with three LDR’s in the same circuit.
Will it work with 8051
I need the hex file sir please
Aslam o Alikum,Brother it is showing an error that ADC_Read is undeclared identifier , compiler i am using is mikroc for pic . Please bro is there any solution
I think you are using MPLAB but this code works with Mikroc for pic
is this code working in keil_v5?
is the code complete ?
pls send me the complete code of this project
its very urgent please…thanks in advance
can you please provide the same code in assembly language for atmega328p