Automatic Room Light Controller using bidirectional visitor counter A Report Report Submitted ubmitted in parti al f ul fi ll ment ment of the requir requir ement ment f or the
Design Project By
SUGANDHA GUPTA Roll No. 1120815 ANOOP YADAV Roll No. 1120816 SANJANA JAIN Roll No. 1120903
Un der der the th e Esteemed Esteemed Gui dance of
ATMA RAM GUPTA (Assistant Professor)
DEPARTMENT OF ELECTRICAL ENGINEERING NATIONAL INSTITUTE OF TECHNOLOGY-KURUKSHETRA KURUKSHETRA-136119 (INDIA)
1
ACKNOWLEDGEMENT We are grateful and express our sincere thanks to our project guide Prof. Atma
Ram
Gupta
Electrical
Engineering
department,
for
helping
in
understanding the concept and for his time to time valuable constant guidance, advice and invaluable suggestions. Without the full support and cheerful encouragement of our teacher, this project would be a dream. Last but not the least, we would like to thank the Teaching & NonTeaching Staff Electrical Engineering Engineering department, we would like to thank one and
all who have helped us during the course of this Project.
2
CONTENTS
INTRODUCTION......................................................................................................................... 4 COMPONENTS DESCRIPTION ............................................................................................... 5
1. I NFRARED SENSORS .............................................................................................................. 6 Principle of Working of IR Sensors ............................................... .......................................... 8 2. ARDUINO UNO MICROCONTROLLER ..................................................................................... 8 3. ALPHANUMERIC LCD DISPLAY ................................................... ........................................ 11 4. R ELAY DRIVER CIRCUIT ..................................................................................................... 11 WORKING ALGORITHM ....................................................................................................... 12 SOFTWARE DESIGN ......................................................................................... ...................... 13
1. 2.
PROCEDURE ........................................................................................................................ 13 FLOW CHART ...................................................................................................................... 14
APPLICATIONS ........................................................................................................................ 17 ADVANTAGES........................................................................................................................... 17 CONCLUSION ............................................................................................ ............................... 18 FUTURE SCOPE........................................................................................................................ 18 REFERENCES................................................ ............................................................................ 19 APPENDIX A .................................................. ............................................................................ 20
3
INTRODUCTION In today’s world with the increasing demand of energy and the continuous depletion of resources there is a need to adopt possible measures to save power wherever possible. With advent of automation technologies, several methods can be applied to avoid wastage of energy. This report proposes an idea to prevent unnecessary consumption of energy in the form of internal electrification of an enclosed space by closing switches of all appliances in the room which are not required to be used when people are not present inside the room. This will be a big step towards the energy efficient lighting systems by optimization of the use of appliances in a room. This will also lead to reduced electricity bills for the consumers and in the long run will become a keystone in modern home automation systems. Often we see visitor counters at stadium, mall, offices, class rooms etc. How they count the people and turn on or off the light when nobody is inside. This report explains the design of a digital visitor counter which uses two Infrared sensor transmitter and receiver pairs to detect the entrance and exit of person in a room. The controlling of the circuit is done using Arduino UNO microcontroller. The outputs of comparators are connected to digital pins of the arduino. Display section will display the counted number of people inside the room. A relay driver circuit is added to get enough voltage and current for relay. Arduino sends commands to this relay driver transistor and then light bulb will turn on and off accordingly. By using digital LCD display the total count of people in the room can be known and this information may be useful for many purposes. The objective of this project is to make a controller based model to count number of persons visiting particular room and accordingly light up the room. Here we can use sensor and can know present number of persons. In today’s world, there is a continuous need for automatic appliances. With the increase in standard of living, there is a sense of urgency for developing circuits that would ease the complexity of life. Also if at all one wants to know the number of people present in room so as not to have congestion, this circuit proves to be helpful. Automatic Room Light Controller with Bidirectional Visitor Counter” is a reliable circuit that takes over the task of controlling the room lights as well us counting number of persons/ visitors in the room very accurately. When somebody enters into the room then the counter is incremented by one and the light in the room will be switched ON and when any one leaves the room then the counter is decremented by one. The light will be only switched OFF until all the persons in the room go out. The total number of persons inside the room is also displayed on the seven segment displays.
4
COMPONENTS DESCRIPTION The various components used in the Hardware design[3-4] of the automatic room light controller using bidirectional digital visitor counter are as discussed below –
- Here we have used +5V dc power supply. The main function of this Power Suppl y block is to provide the required amount of voltage to essential circuits. +5V is given to relay driver. To get the +5V dc power supply arduino is used as the source and no separate dc supply will be required.
- This is one of the main parts of our project. The main Enter and Ex it Sensor Cir cuit intention of this block is to sense the person. For sensing the person we are using a TSOP1738 sensor. By using this sensor and its related circuit diagram we can count the number of persons.
- The Arduino Uno is a microcontroller board based on Ar duin o UN O microcontr oller the ATmega328 . It has 14 digital input/output pins of which 6 can be used as PWM outputs, 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button[1]. It contains everything needed to support the microcontroller.
- In this section we have used LCD displays to display Al phanumeri c LCD display number of persons in the room. We have used transistor for display drive circuit. This display should be placed outside the room. It displays various messages like “Person Counter Incremented”, “Person Counter Decremented”, “No of Person in Room = XYZ” here XYZ is the actual person count.
- In this section we have used the transistor and the relays. Output Relay Dri ver Cir cuit signal from microcontroller is given to the base of the transistor, which energizes the particular relay, because of this, appropriate device is selected and which performs its allotted function.
5
Fig. 1. Block diagram of Automatic light controller
The description of the various components is as given below -
1. Infrared Sensors A passive infrared sensor (PIR sensor) is an electronic sensor that measures infrared (IR) light radiating from all objects with a temperature above absolute zero emit heat energy in the form of radiation[2]. Usually this radiation is invisible to the human eye because it radiates at infrared wavelengths, but it can be detected by electronic devices designed for such a purpose. The term passive in this instance refers to the fact that PIR devices do not generate or radiate any energy for detection purposes. They work entirely by detecting the energy given off by other objects.PIR sensors don't detect or measure "heat"; instead they detect the infrared radiation emitted or reflected from an object in its field of view. They are most often used in PIR-based motion detectors. The wavelengths of these regions and their applications are shown below. Near infrared region — 700 nm to 1400 nm — IR sensors, fiber optic Mid infrared region — 1400 nm to 3000 nm — Heat sensing Far infrared region — 3000 nm to 1 mm — Thermal imaging
The frequency range of infrared is higher than microwave and lesser than visible light. They are of two types: quantum and thermal. 6
IR Transmitter
Infrared Transmitter is a light emitting diode (LED) which emits infrared radiations. Hence, they are called IR LED’s. Even though an IR LED looks like a normal LED, the radiation emitted by it is invisible to the human eye. There are different types of infrared transmitters depending on their wavelengths, output power and response time[2]. A simple infrared transmitter can be constructed using an infrared LED, a current limiting resistor and a power supply. The schematic of a typical IR transmitter is shown below When operated at a supply of 5V, the IR transmitter consumes about 3 to 5 mA of current. Infrared transmitters can be modulated to produce a particular frequency of infrared light. The most commonly used modulation is OOK (ON – OFF – KEYING) modulation. IR transmitters can be found in several applications. Some applications require infrared heat and the best infrared source is infrared transmitter. When infrared emitters are used with Quartz, solar cells can be made.
IR Receiver
Infrared receivers[2] are also called as infrared sensors as they detect the radiation from an IR transmitter. IR receivers come in the form of photodiodes and phototransistors. Infrared Photodiodes are different from normal photo diodes as they detect only infrared radiation. Different types of IR receivers exist based on the wavelength, voltage, package, etc. When used in an infrared transmitter – receiver combination, the wavelength of the receiver should match with that of the transmitter. A typical infrared receiver circuit using a phototransistor is shown below. It consists of an IR phototransistor, a diode, a MOSFET, a potentiometer and an LED. When the phototransistor receives any infrared radiation, current flows through it and MOSFET turns on. This in turn lights up the LED which acts as a load. The potentiometer is used to control the sensitivity of the phototransistor.
Fig. 2. IR Sensor Circuit Diagram
7
Principle of Working of IR Sensors The principle of an IR sensor working as an Object Detection Sensor can be explained using the following figure. An IR sensor consists of an IR LED and an IR Photodiode; together they are called as Photo – Coupler or Opto – Coupler. When the IR transmitter emits radiation, it reaches the object and some of the radiation reflects back to the IR receiver. Based on the intensity of the reception by the IR receiver, the output of the sensor is defined[3]. It consists of an IR LED, a photodiode, a potentiometer, an IC Operational amplifier and an LED. IR LED emits infrared light. The Photodiode detects the infrared light. An IC Op – Amp is used as a voltage comparator. The potentiometer is used to calibrate the output of the sensor according to the requirement. When the light emitted by the IR LED is incident on the photodiode after hitting an object, the resistance of the photodiode falls down from a huge value. One of the input of the op – amp is at threshold value set by the potentiometer. The other input to the op-amp is from the photodiode’s series resistor. When the incident radiation is more on the photodiode, the voltage drop across the series resistor will be high. In the IC, both the threshold voltage and the voltage across the series resistor are compared. If the voltage across the resistor series to photodiode is greater than that of the threshold voltage, the output of the IC Op – Amp is high. As the output of the IC is connected to an LED, it lightens up. The threshold voltage can be adjusted by adjusting the potentiometer depending on the environmental conditions. The positioning of the IR LED and the IR Receiver is an important factor. When the IR LED is held directly in front of the IR receiver, this setup is called Direct Incidence. In this case, almost the entire radiation from the IR LED will fall on the IR receiver. Hence there is a line of sight communication between the infrared transmitter and the receiver. If an object falls in this line, it obstructs the radiation from reaching the receiver either by reflecting the radiation or absorbing the radiation.
2. Arduino UNO microcontroller The Arduino Uno is a microcontroller board based on the ATmega328 (datasheet). It has 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. It contains everything needed to support the microcontroller. It is simply connected to a computer with a USB cable or powered with a AC-to-DC adapter or battery to get started[1]. The technical specifications of Arduino UNO are -
8
Microcontroller ATmega 328 Operating Voltage - 5V Input Voltage (recommended) - 7-12V Input Voltage (limits)- 6-20V Digital I/O Pins - 14 (of which 6 provide PWM output) Analog Input Pins - 6 DC Current per I/O Pin - 40 mA DC Current for 3.3V Pin - 50 mA Clock Speed - 16 MHz
Arduino is an open-source microcontroller platform with development environment that implements Processing/Wiring language which is a subset of C and includes several libraries. In order to maximize performance and parallelism, the AVR uses Harvard architecture with separate memories and buses for program and data. Instructions in the program memory are executed with a single level pipelining. Modular design of Arduino board allows easy and fast integration with other hardware (eg. displays, motors, keyboards ) and makes AVR microcontroller easier to program. Arduino’s processor basically uses the Harvard architecture where the program code and program data have separate memory. It consists of two memories- Program memory and the data memory[3]. The code is stored in the flash program memory, whereas the data is stored in the data memory. The Atmega328 has 32 KB of flash memory for storing code (of which 0.5 KB is used for the boot loader), 2 KB of SRAM and 1 KB of EEPROM and operates with a clock speed of 16MHz. Arduino Uno consists of 14 digital input/output pins (of which 6 can be used as PWM outputs), 6 analog inputs, a 16 MHz crystal oscillator, a USB connection, a power jack, an ICSP header, and a reset button. Power Jack : Arduino can be power either from the pc through a USB or through external source like adaptor or a battery. It can operate on a external supply of 7 to 12V. Power can be applied externally through the pin Vin or by giving voltage reference through the IO Ref pin. Digital Inputs : It consists of 14 digital inputs/output pins, each of which provide or take up 40mA current. Some of them have special functions like pins 0 and 1, which act as Rx and Tx respectively , for serial communication, pins 2 and 3-which are external interrupts, pins 3,5,6,9,11 which provides pwm output and pin 13 where LED is connected. Analog inputs: It has 6 analog input/output pins, each providing a resolution of 10 bits. A Ref : It provides reference to the analog inputs 9
Reset: It resets the microcontroller when low.
The most important advantage with Arduino is the programs can be directly loaded to the device without requiring any hardware programmer to burn the program. This is done because of the presence of the 0.5KB of Boot loader which allows the program to be burned into the circuit. Programs written in Arduino are known as sketches. A basic sketch consists of 3 parts1. Declaration of Variables 2. Initialization: It is written in the setup () function. 3. Control code: It is written in the loop () function. o
o o o
The sketch is saved with in extension. Any operations like verifying, opening a sketch, saving a sketch can be done using the buttons on the toolbar or using the tool menu. The sketch should be stored in the sketchbook directory. Chose the proper board from the tools menu and the serial port numbers. Click on the upload button or chose upload from the tools menu. Thus the code is uploaded by the boot loader onto the microcontroller [4-5].
Fig. 3. Arduino UNO block diagram
Arduino is widely preferred now a days the reason being it’s the various advantages. It comes with an open source hardware feature which enables users to develop their own kit using already available one as a reference source. The Arduino software is compatible with all types of operating systems like Windows, Linux, and Macintosh etc. It also comes with an open source software feature which enables experienced software developers to use the Arduino code to merge with the existing programming language libraries and can be extended and modified.
10
3. Alphanumeric LCD display Alphanumeric displays are used in a wide range of applications, including palmtop computers, word processors, photocopiers, point of sale terminals, medical instruments, cellular phones, etc. The 16 x 2 intelligent alphanumeric dot matrix display is capable of displaying 224 different characters and symbols.
Fig. 4. 1x 16x2 Alphanumeric Display
4. Relay Driver Circuit Relay driver section consist a BC547 transistor and a 5 volt relay for controlling the light bulb. Transistor is used to drive the relay because arduino does not supply enough voltage and current to drive relay[6]. So we added a relay driver circuit to get enough voltage and current for relay. Arduino sends commands to this relay driver transistor and then light bulb will turn on/off accordingly.
Fig. 5. Relay
11
Fig. 6. Relay Driver Circuit
WORKING ALGORITHM The whole working of the automatic room light controller[3][4] with digital visitor counter is based upon the action of sensors with signal processed by the arduino UNO controller[1] which in turn drives the relay to control switching of the equipments inside the room. The basic block diagram of the bidirectional digital visitor counter[5] is shown above. Two pairs of Infrared transmitter and receivers are placed at the entry of the closed room in such a manner that sensor pair 1 falls before the sensor pair 2 in the arrangement. IR sensors are being used because they cannot be detected by human eyes. Also IR sensors possess another advantage that they are not triggered by any other source in the environment. If the sensor 1 is interrupted first then the controller will look for sensor 2 and if it is interrupted then the arduino will increment the count and will switch the relay. If the sensor 2 is interrupted first then the controller will look for sensor 1 and if it is interrupted then the arduino will decrement the count and will switch the relay. Figure7 represents the interfacing of various circuit components along with the pin connections. Here in this circuit we have used two comparators for two IR sensors. LM358 is used as comparator. LM358 has inbuilt two low noise Op-amp. The output pins of the sensor are connected to the digital pin no. 14(A0) and 19(A5) of the Arduino UNO R3 which are the input pins as shown. Arduino read these signals and send commands to relay driver circuit to drive the relay for light bulb controlling. Relay driver section consist a BC547 transistor and a 5 volt relay for controlling the light bulb. The relay driver transistor is connected to digital pin 2 of the Arduino. LCD is connected in 4 bit mode. RS and EN pin of LCD is directly connected at 13 and 12. Data pin of LCD D4-D7 is also directly connected to arduino at D11-D8 respectively.
12
Fig. 7. Interfacing Circuit
SOFTWARE DESIGN 1. Procedure Automatic room light controller follows the following steps: 1. There are two sensing device which are located at the exit and enter of the entrance of the room[7-9] .IR transmitter transmit the signal to the receiver by generating the modulated IR signal. 2. As shown the figure[8] if the sensor 1 is interrupted first that means a person is entering from the door then Arduino UNO microcontroller is look for sensor 2 and if it is interrupted then the microcontroller increment the count and displayed it in the LCD display. 3. The count which is being displayed in the LCD display is equal to the number of people in the room and accordingly the lights of the room will turn on by using relay. 4. If the sensor 2 is interrupted first the microcontroller look for the sensor 1. And if sensor 1 will interrupt after sensor 2 then microcontroller decrement the count and displayed it on LCD display. 5. When the last person leaves the room the counter goes to zero that time the relay will turn off and all the light will turn off.
13
2. Flow Chart The flow chart below explains the block wise working of the whole process of the test set-up. Infrared transmitter and receivers are placed at the entry of the closed room in such a manner that sensor pair 1 falls before the sensor pair 2 in the arrangement. IR sensors are being used because they cannot be detected by human eyes. Also IR sensors possess another advantage that they are not triggered by any other source in the environment. If the sensor 1 is interrupted first then the controller will look for sensor 2 and if it is interrupted then the arduino will increment the count and will switch the relay. If the sensor 2 is interrupted first then the controller will look for sensor 1 and if it is interrupted then the arduino will decrement the count and will switch the relay.
Fig. 8. FLOW CHART of Automatic room light controller
14
Code Explanation
The coding for the arduino microcontroller is the major play master of the whole project. Arduino programming is basically a physical computing process. Physical computing is concerned with developing software that interacts with the world beyond the host computer through a combination of hardware and software. The Arduino interacts with the world through actuators and sensors. One common way sensors work is that their electrical properties change as an effect of the changes in the conditions in which it is operating. Actuators, on the other hand, are electronic components that are used to react to an external event. Sensors and actuators, thus, are used to achieve complementary objectives: one senses, and the other reacts. The Arduino is an open-source electronics prototyping platform composed of two major parts: the Arduino board which is the hardware interface and the Arduino IDE which is the software. The Arduino IDE is used to write the program that will interact with Arduino board and the devices connected to it. In the Arduino world, such a program is called a sketch, which has its origin in its mother language.
First the library for LCD is included and pins are defined for the same. And also input output pins are defined for sensors and relay. The pins for LCD are from 9 to 13. Input pin is at 6 output pin is at 7 and relay is connected at pin 2. #include #define in1 6 #define in2 7 #define relay 2 #define in 1 #define out 2
Next a loop is created which is used for initialization of the LCD setup. At the beginning of the program the LCD will display a message of “Visitor Counter”. Using the pinmode function the pins ‘in’ and ‘out’ are defined as input pins and ‘relay’ is defined as output pin. void setup() { lcd.begin(16,2); lcd.print("Visitor Counter"); delay(2000); pinMode(in, INPUT);
15
pinMode(out, INPUT); pinMode(relay, OUTPUT); lcd.clear(); lcd.print("Person In Room:"); lcd.setCursor(0,1); lcd.print(count); }
In loop function we read sensors input and increment or decrement the counting depending upon enter or exit operation. And also check for zero condition. Zero condition means no one in the room. If zero condition is true then arduino turn off the bulb by deactivating the relay through transistor. void loop() { switch(humanDirection) { case in: countPlus(); break; case out: countMinus(); break; case 0: break; } if(count<=0) { count = 0; lcd.clear(); digitalWrite(relay, LOW); lcd.clear(); lcd.print("Nobody In Room"); lcd.setCursor(0,1); lcd.print("Light Is Off"); delay(200); }
16
And if zero condition is false then arduino turns on the light. Here is two functions for enter and exit.
void countPlus() { count++; lcd.clear(); lcd.print("Person In Room:"); lcd.setCursor(0,1); lcd.print(count); delay(1000); } void countMinus() { count--; lcd.clear(); lcd.print("Person In Room:"); lcd.setCursor(0,1); lcd.print(count); delay(1000);
} The code is given in appendix A
APPLICATIONS
It can be used in various rooms like seminar halls , where the capacity of the room is limited and should not be exceeded[10] It can be used in our homes because we often forget to switch off our room lights It helps in energy conservation In future , we can send this data to remote areas using mobile or internet Voice alarm system can be used to indicate that room is full & person can’t enter inside
ADVANTAGES Main advantage of this project is that it helps in energy conservation. Because when there is nobody inside the room then lights are automatically turned off. Human efforts to count the number of person are eliminated[11]. Since this project does the automatic person counting with the help of two sensors installed on door frame.
17
CONCLUSION The following project has been developed as the part of home automation system that aims at reducing the wastage of energy at work places and at home. Also the set up enables the person to know the number of people present in an enclosed space. Such a knowledge is useful when there is a need to reduce congestion in the room or to know the exact number of people present at a social gathering like a sports complex or a conference room etc. Such a project can prove to be very useful in terms of increasing concerns for security issues in today’s world. Also it would prevent any unnecessary wastage of energy which may be caused due to human negligence. Digital Visitor Counter can be used in various rooms like seminar hall, conference hall where the capacity of room is limited and should not be exceeded. Project will display actual number of persons inside the room. This project can be used in Cinema halls, multiplex, malls as well as in temples to count the number of person entering inside. So that these places should not get over crowded to avoid congestion. It can also be used in classrooms and study rooms in schools and colleges.
FUTURE SCOPE To make further enhancements in our project a very good addition will be that of a LDR[4] which is Light Dependent Resistor[4]. It controls the amount of lighting in a room by constantly monitoring the level of luminance in a room .LDR is a variable resistor whose resistance is inversely proportional to the intensity of the incident light. As it is a passive transducer, a potential divider circuit is used to obtain the corresponding voltage value from the LDRs. The higher the intensity of light, lower the LDR resistance and hence lower the output voltage and vice versa. Lights are then controlled such that required illumination is available in the room. It can be applied effectively in commercial buildings, homes, colleges etc. On a normal day when there is a bright sun the lights will be OFF. And on a cloudy day the illumination levels will be low the controller calculates the required lighting by checking the illumination level and turns ON the lights. Thus we can reduce the unnecessary wastage of energy. We can automatically monitor the light availability in a room. Light intensity in the range of 90 to 100 percent is optimum for normal sight. If intensity is greater than 90 percent, no lighting is required. Subsequently for every 20 percent drop in intensity a 10 Watts lamp is turned ON to maintain o ptimum lighting.
18
REFERENCES [1] G. Smith, Introduction to Arduino, September 30, 2011 [2] T. S. Jayadev, Infrared sensors: detectors, electronics, and signal processing, Society of th Photo-optical Instrumentation Engineers 24 july 1999 [3] http://circuitdigest.com/microcontroller-projects/automatic-room-light-controller-with bidirectional-visitor-counter-using-arduino [4]
hTTps://en.wikipedia.org/wiki/Integrated_development_environment
[5] http://www.engineersgarage.com/tutorials/555-timer-ic-introduction-basics-workingdifferent-operating-modes [6]
http://www.ti.com/product/LM358
[7]
http://www.slideshare.net/SINGHNIKHIL/automaticroomlightcontrollerwithbidirectional
[8]
http://www.electrical4u.com/light-dependent-resistor-ldr-working-principle-of-ldr
[9] http://www.academia.edu/1409805/Automatic_Room_Light_Controller_with_Bidirectio nal_Visitor_Counter
[10] https://www.elprocus.com/know-about-working-of-automatic-room-light-controller-andapplications/
[11] http://seminarprojects.org/c/advantages-and-disadvantages-of-automatic-room-lightcontroller-with-bidirectional-visitor-counter
/
19
APPENDIX A
Code
#include #define in1 6 #define in2 7 #define relay 2 #define in 1 #define out 2 int count = 0; LiquidCrystal lcd(13,12,11,10,9,8); int timeDiff = 0; int humanDirection = 0; int time1 = 0; int time2 = 0; void directionDetect() { while((digitalRead(in1) || digitalRead(in2)) != 1); if(digitalRead(in1)) { time1 = millis(); while(digitalRead(in2) != 1); time2 = millis(); timeDiff = time2 - time1; humanDirection = in; } else if(digitalRead(in2)) { time2 = millis(); while(digitalRead(in1) != 1); time1 = millis(); timeDiff = time1 - time2; humanDirection = out; } } void countPlus() { count++; lcd.clear(); lcd.print("Person In Room:"); lcd.setCursor(0,1); lcd.print(count); delay(1000); } 20
void countMinus() { count--; lcd.clear(); lcd.print("Person In Room:"); lcd.setCursor(0,1); lcd.print(count); delay(1000); } void setup() { lcd.begin(16,2); lcd.print("Visitor Counter"); delay(2000); pinMode(in, INPUT); pinMode(out, INPUT); pinMode(relay, OUTPUT); lcd.clear(); lcd.print("Person In Room:"); lcd.setCursor(0,1); lcd.print(count); } void loop() { switch(humanDirection) { case in: countPlus(); break; case out: countMinus(); break; case 0: break; } if(count<=0) { count = 0; lcd.clear(); digitalWrite(relay, LOW); lcd.clear(); lcd.print("Nobody In Room"); lcd.setCursor(0,1); lcd.print("Light Is Off"); delay(200); } 21
else digitalWrite(relay, HIGH); directionDetect(); if(timeDiff > 3000) { timeDiff = 0; humanDirection = 0; } } END
22