Вы находитесь на странице: 1из 35

ELECTRONICS HUB

PROJECTS | TUTORIALS | COURSES | KITS

 HOME

 PROJECTS
o MINI PROJECTS
 TOP ELECTRONICS
 MICROCONTROLLER
o ELECTRICAL
 TOP ELECTRICAL
o ELECTRONICS
 TOP
 LATEST
 LED
 VLSI
 MATLAB
 SENSOR
o HOME AUTOMATION
o RASPBERRY PI
o IOT
o EMBEDDED
 8051
 AVR
 PIC
o COMMUNICATION
 DTMF
 GSM
 RFID
 WIRELESS
o POWER ELECTRONICS
o ARM PROJECTS
o ROBOTICS
o SOLAR

 MINI PROJECTS

 ARDUINO

 FREE CIRCUITS
o MINI PROJECTS
o ELECTRONICS
 555 TIMER
o EMBEDDED
 8051
 AVR
o COMMUNICATION
o ELECTRICAL
o ROBOTICS
o SOLOR
o SENSOR

 TUTORIALS
o CAPACITORS
o RESISTORS
o FILTERS
o OPERATIONAL AMPLIFIERS
o DIODES
o TRANSISTORS
o NUMBER SYSTEMS
o IO DEVICES
o MISCELLANEOUS
o DC CIRCUIT THEORY
o THYRISTORS
o SEQUENTIAL LOGIC CIRCUITS

 SYMBOLS

 DIY

 COURSES

 CONTACT US
o FOLLOW US
 FACEBOOK
 YOUTUBE
 INSTAGRAM
 GOOGLE PLUS
 TWITTER

YOU ARE HERE: HOME / FREE PROJECT CIRCUITS / EMBEDDED / 8051 MICROCONTROLLER / AUTOMATIC
ROOM LIGHTING SYSTEM USING MICROCONTROLLER

Automatic Room Lighting System


using Microcontroller
JUNE 16, 2017 BY ANUSHA 40 COMMENTS
Automatic Room Lighting System is a microcontroller based project that automatically
turn on or off the lights in a room. Electricity, being one of the most important resources,
must be utilized carefully.

We often forget to switch off lights or fans when we leave a room. By using this system,
we can intentionally forget about the lights as the system will automatically take care of
them.

The digital World we are living in allows us to use different technologies to automatically
perform certain tasks. Such automation is very useful in certain areas like energy
consumption, reducing human efforts, improving standard of living etc.

The project implemented here is one such project where the microcontroller based
system automatically controls the room lights.
The aim of this project is to automatically turn on or off the lights in a room by detecting
the human movement. We implemented this project using 8051 Microcontroller and two
Infrared (IR) sensors.

Since the job of the circuit is to turn on the light when someone enters the room and
turn off the light when the last person leaves the room, the project has to internally
count the number of visitors entering and leaving the room. Hence, the project acts as
an Automatic Room Lighting System as well as Bidirectional Visitor Counter.

Warning: A 230V light bulb is used in this project and is connected to relay and mains
supply. You should be very careful when connecting the mains wires.

Table of Contents
 Components Required
 Circuit Description
 Component Description
o IR Sensor Module
o 5V Relay Module
 Working of the project
 Code
 Applications
 Construction and Output Video

Components Required
 AT89C51 Microcontroller (any 8051 architecture based microcontroller)
 8051 Development Board
 2 x Infrared Sensors
 16 x 2 LCD Display
 5V Relay Module
 Lamp
 Connecting Wires
 Power Supply

Circuit Description
Let us see the design of the circuit for automatic room lighting project. The circuit
diagram shows all the connections with respect to microcontroller. If you are doing this
project on a development board, some of the connections mentioned in the circuit
diagram might not be necessary.
Also, we have used modules for Relay and IR Sensor and hence, the connections are
shown with respect to those modules only. Corresponding circuit diagrams are also
provided.

Coming to the circuit design, a 16 x 2 LCD Display, two IR Sensors and a 5V Relay
Module must be connected to the 8051 Microcontroller. First, connect the 8 data pins of
the LCD to PORT1 pins i.e. P1.0 to P1.7.

The 3 control pins of LCD i.e. RS, RW and E are connected to P3.6, GND and P3.7 pins
respectively. A 10 KΩ Potentiometer is connected to contrast adjust pin of LCD i.e. its
pin 3.

Two Reflective type IR Sensors are connected to PORT2 pins i.e. P2.0 and P2.1.
Detailed circuit of the IR Sensor is mentioned in the Component Description.

The input of the 5V Relay is connected to PORT0 pin P0.0. The detailed circuit of the
5V Relay module used in the project is explained in the component description section.
Alternatively, you can construct the circuit as per the circuit diagram (which consists of
5V Relay, Transistor, Diode and a Resistor).

Component Description
IR Sensor Module
An Infrared or IR Sensor is a simple circuit that is used to detect objects (Proximity
Sensor) or measure distance (Range Finder). An IR Sensor consists of 3 components:
an IR Transmitter (IR LED), an IR Receiver (like a Photo Diode) and a signal processing
circuit.

We have used reflective type IR sensor modules in this project. The detailed circuit
diagram of the module is shown in the following image.
5V Relay Module
A 5V Relay Module is used in this project which helps 8051 Microcontroller to operate
high voltage AC loads like a light. The detailed circuit of the Relay Module is shown in
the following image. It consists of a 5V Electromechanical Relay, an Optocoupler IC,
transistor, two resistors and two diodes.
Working of the project
In this project, an automatic room lighting system is developed using 8051
microcontroller. The working of the project is explained here.

The main component of the project is IR Sensor and we have used two of them. The
placement of the sensors is important as it will determine the functioning of the project.

Practically speaking, both the sensors must be placed on the either side of the door or
entrance of the room. The sensor placed on the outside of the room is named as
Sensor 1 and the sensor, which is placed on the inside is named Sensor 2.

When a person tries to enter the room, Sensor 1 detects the person first and then
Sensor 2. This action will indicate the 8051 Microcontroller that the person is entering
the room.

Hence, the microcontroller will turn on the light and also increments the visitor counter
to 1. If there are more visitor, the microcontroller will keep the light turned on and
increments the visitor counter accordingly.

When a person tries to leave the room, Sensor 2 detects the person first and then
Sensor 1. This process will make the microcontroller to understand that a person is
trying to leave the room and hence, it will decrement the count of visitors. The
microcontroller will not turn off the light until the last person has left the room.

As the visitors start leaving the room, the visitor count will be decremented and when
the last person leaves the room, the count be comes 0. During this point, the
microcontroller understands that there is nobody in the room and turns OFF the light.

Caution: Be extremely cautious when using 230V mains supply.

Code
#include<reg51.h>

#define lcd P1
sbit rs=P3^6;
sbit e=P3^7;
sbit relay=P0^0;
sbit s1=P2^0;
sbit s2=P2^1;
void delay (int);
void cmd (char);
void display (char);
void init (void);
void string (char *);
void view (int);
int count=0;
int no[10]={48,49,50,51,52,53,54,55,56,57};
void delay (int d)
{
unsigned char i=0;
for(;d>0;d--)
{
for(i=250;i>0;i--);
for(i=248;i>0;i--);
}
}
void cmd (char c)
{
lcd=c;
rs=0;
e=1;
delay(5);
e=0;
}
void display (char c)
{
lcd=c;
rs=1;
e=1;
delay(5);
e=0;
}
void string (char *p)
{
while(*p)
{
display(*p++);
}
}
void view (int n)
{
cmd(0xc0);
display(no[(n/10)%10]);
display(no[n%10]);
}
void init (void)
{
cmd(0x38);
cmd(0x0c);
cmd(0x01);
cmd(0x80);
}
void main()
{
init();
string("counter........");
cmd(0xc0);

view(count);

while(1)
{
if(s1==1)
{
while(s2==0);
if(count!=99)
count=count+1;
while(s2==1);
view(count);
}
else if(s2==1)
{
while(s1==0);
if(count!=0)
count=count-1;
while(s1==1);
view(count);
}
else if(count==1)
relay=0;
else if(count==0)
relay=1;

}
}

view rawAutomatic Room Lighting System using Microcontroller hosted with by GitHub

Applications
 Automatic Room Lighting with Bidirectional Visitor Counter can be used to
automatically turn on the light in a room when a person enters the room and turn it
off when the person leaves the room.
 The project can also be dubbed as a Bidirectional Visitor Counter it is an integral
part of the Automatic Room Lighting circuit.
 The project can be modified with LEDs and as the number of persons in the room
increases, the number of LEDs turning ON also increases.

Construction and Output Video


FILED UNDER: 8051 MICROCONTROLLER, EMBEDDED

Comments

1. SARAT CHANDRA ROUT says

JUNE 16, 2017 AT 9:43 AM

Very good circuit for me. I want this Micro ic is also used for automatic water level
controlER. Please give me the circuit details.
Thanks

Reply

o Anusha says

JUNE 19, 2017 AT 1:03 AM

Here is the circuit of water level controller using


8051…https://www.electronicshub.org/water-level-controller-using-8051-
microcontroller/…We are also providing a course on this project check it
here..http://courses.electronicshub.org/p/water-level-controller.You can find detailed
explanation on circuit along with code..

Reply
2. Akhtar Raza says

JUNE 16, 2017 AT 4:05 PM

This project was tested?

Reply

o Anusha says

JUNE 19, 2017 AT 12:59 AM

Yes. Output video will be updated soon..

Reply

3. Shubham says

JUNE 23, 2017 AT 5:15 AM

When will you upload the output Vedio. And this circuit is tested or not
Reply

o Anusha says

JULY 7, 2017 AT 2:46 AM

Hi, The project and the code are tested and we will upload the video very soon.

Reply

4. Sai teja says

JUNE 28, 2017 AT 4:42 AM

Thank you for this circuit

but how can i install this to my room ????

how should i arrange the sensors ??(on either side of the room door??)

what software should i use to dump the given code

can this control multiple devices like a fan and light at a time ???

what is the maximum sensing distance of these IR sensors??


Hope you help me with the details

Reply

o Anusha says

JULY 7, 2017 AT 2:45 AM

Hi, You can install the sensors on either side of the wall where the door opens (not on the
door). We have used the software bundled with the programmer we are using. So, the
software used for dumping the code depends on the programmer hardware (burner). Yes. It
can control multiple devices. You need a multi-channel relay board for that. The maximum
distance between the individual sensors can be pretty large depending on the wiring (Do not
go for more than 30CM)

Reply

5. Vinayak says

AUGUST 5, 2017 AT 8:26 AM

Can u pls tell me hw can i upload the codes to the ic

Reply
6. Rajat Saraswat says

AUGUST 25, 2017 AT 12:28 PM

Hi. Can I make this circuit in engineering project? Is it in working mode?

Reply

7. chandana says

OCTOBER 17, 2017 AT 10:06 AM

Provide the complete components requirements in hardware with each and every
component values and software tools

Reply

o AsMa says

SEPTEMBER 11, 2018 AT 1:09 PM

Can u give me the complete decription of components used such as those used for lcd
display .i m not getting the idea from video what are those???
Reply

 Karan says

OCTOBER 28, 2018 AT 12:28 AM

16×2 lcd display

Reply

8. Devashish says

OCTOBER 26, 2017 AT 1:52 PM

Can these codes be used in other microcontroller like Atmega328p or any other IC

Reply

9. Nabil says
NOVEMBER 10, 2017 AT 4:40 AM

I tried doing this but somehow it doesn’t work. The count only goes up and never down
no matter where you swipe. Please help.

Reply

10. NITHYA says

NOVEMBER 16, 2017 AT 1:15 PM

What is the model of the IR sensor being used? Is there any replacement that we could
use for the same.

Reply

11. Turbo says

DECEMBER 1, 2017 AT 9:02 AM

Is it a complete project code? bcoz I am testing on Proteus 7 professional simulator and


it not running.

Reply
12. Azka Ihtesham says

DECEMBER 24, 2017 AT 7:14 AM

Hi
Iam getting trouble in dumping the program in the circuit please guide me.

Reply

13. Azka Ihtesham says

DECEMBER 24, 2017 AT 7:19 AM

Iam using USBSP as connector to circuit and the laptop.


And PROGISP as the programmer. While dumping the program it is displaying chip
enble error.

Reply

14. kalyan says

FEBRUARY 15, 2018 AT 10:30 AM

i am using at89s52 development board.it works or not..?


Reply

15. Adam N Ibrahim says

FEBRUARY 24, 2018 AT 1:07 PM

Mmmm very interesting. Please help me to build this as my project

Reply

o Ravi says

FEBRUARY 25, 2018 AT 11:30 PM

Circuit Diagram, Components and Code is already provided.

Reply

16. Alvish Ram says


MARCH 8, 2018 AT 6:27 PM

In which software can i build this code given above.

Reply

o Ravi says

MARCH 8, 2018 AT 11:25 PM

Keil µVision.

Reply

17. Sweety says

MARCH 30, 2018 AT 10:34 PM

Is this 8051 Development Board available online ?

Reply
o Ravi says

MARCH 31, 2018 AT 12:08 AM

Yes. I Think. Try Amazon.

Reply

18. sandy says

APRIL 1, 2018 AT 6:00 AM

ATMEL 8051 Project Development Board On-Board AT89S52,MAX232 Support


AT89SXX,P89V51RD2,SST89E516RD

can any of these run?

Reply

o Ravi says

APRIL 9, 2018 AT 1:20 AM


Yes.

Reply

19. Avhad says

APRIL 5, 2018 AT 12:10 AM

Coding is unable to run


What to do ?

Reply

20. Vedant says

APRIL 6, 2018 AT 9:25 AM

Can u send me the value of optocopler ic

Reply
o Ravi says

APRIL 9, 2018 AT 12:26 AM

It is 817C. It is a part of the Relay Board we have used.

Reply

21. SASWAT SUBHAJYOTI MALLICK says

MAY 21, 2018 AT 3:34 AM

Is the IR sensor used PIR or sound based?

Reply

22. sugar kammar says

JUNE 11, 2018 AT 9:34 AM

In these project when I’m using ir sensors that time it will not work correctly but ir
sensors reaplce in switch that time it will correctly work why
Reply

23. Gcini says

JUNE 13, 2018 AT 3:24 PM

Why you chose this design?

Reply

24. Shravani says

JULY 2, 2018 AT 4:10 AM

what is the purpose of using this 8051 board ? Can we use an aurdino board instead ?

Reply

25. Shravani says


JULY 2, 2018 AT 4:13 AM

What is the purpose of the 8051 board ? Can we use an aurdino board instead ?

Reply

26. Likitha says

JULY 2, 2018 AT 5:05 AM

What is the purpose of 8051 development board ? Can we use an aurdino board ?

Reply

27. jeff says

SEPTEMBER 28, 2018 AT 5:05 AM

can you sell me this project when it’s completely done and working coz I have tried
severally but it didn’t work

Reply
28. Tikshan says

OCTOBER 25, 2018 AT 8:13 AM

Sir, can you please tell me how i cam burn code in the microcontroller.

Reply

29. Karan says

OCTOBER 28, 2018 AT 12:25 AM

How supply is given to the development board


Through batteries
Or adaptor

Reply

Leave a Reply
Your email address will not be published. Required fields are marked *

Comment
Name *

Email *

Website

PROJECTS BY CATEGORY

Arduino Projects (200+)


Electronics Projects (250+)
Mini Project Circuits (160+)
Mini Project Ideas (150+)
ECE Projects (150+)
EEE Projects (150+)
8051 Projects (110+)
Raspberry Pi Projects (101+)
Electrical Project Ideas (100+)
Embedded Projects (100+)
Latest Electronics Ideas (100+)
Microcontroller Mini Projects (100+)
Robotics Projects (100+)
VLSI Projects (100+)
Solar Projects (100+)
IOT Projects (100+)

Communication Projects (70+)


LED Projects (70+)
Power Electronics Projects (60+)
RFID Projects (60+)
Home Automation Projects (50+)
Matlab Projects (50+)
EIE Projects (50+)
Wireless Projects (50+)
LabView Projects (45+)
Zigbee Projects (45+)
GSM Projects (40+)
555 Timer Circuits (40+)
Sensor Projects (40+)
ARM Projects (60+)
DTMF Projects (30+)
PIC Projects (30+)
Electrical Mini Projects (25)
ESP8266 Projects (15)

KITS

Best Drone Kits [12]


3D Printer Kits [12]
Best Robot Vacuum Clears [14]
Best Waveform Generators [12]
RGB LED Strip Light Kits [20]
Best LED Christmas Light Kits [13]

SUBSCRIBE FOR UPDATES

Enter your email address:

GENERAL
 Tutorials
 Symbols
 Courses
 Calculator
 Contact
PROJECTS

 Electrical
 Electronics
 Embedded
 Power
 Robotics
 ARM
 IOT
PROJECTS

 Mini projects
 Microcontroller
 Arduino
 Solar
 Free circuits
 Home Automation
 Seminar Topics
 Electronics Questions
TUTORIALS

 Capacitors
 Resistors
 Filters
 Diodes
 Transistors
TUTORIALS

 Amplifiers
 IO Devices
 Thyristors
 DC Circuits
 Number System
 TS EAMCET 2019
FOLLOW US

 Instagram
 Youtube
 Facebook
 Google Plus
 Twitter
Copyright © 2019 Electronicshub.org