Bidirectional visitor counter can detect whether a room is empty or not, and then switch on or off lights and fans in the room based on the occupancy level

Let's get started with this creative Arduino project, where you'll learn how to make a bidirectional visitor counter that can detect whether a room is empty or not, and then switch on or off lights and fans in the room based on the occupancy level. It can also be used to establish social distance in stores, Saloon, banks and among other places. 

Components Required

What is an IR proximity sensor and how does it work?

What is an IR proximity sensor and how does it work?, proximity sensor, proximity sensor pinout, ir sensor

A proximity sensor is a sensor which detects the presence of nearby objects without any physical contact. Any nearby surface reflects IR radiation emitted by an IR LED. An IR receiver located next to the emitter detects the reflected rays. The intensity of light falling on the receiver varies depending on the distance between the obstacle and the sensor.
As a result, high-intensity light reflected back indicates the presence of an obstacle or a nearby surface. In most cases, these sensors are digital (or sometimes analog).

How to Interface 16x2 LCD with Arduino Uno ?

LCD modules are a critical component in many Arduino-based embedded systems. As a result, understanding how to attach an LCD module to an Arduino is crucial when designing embedded systems. Here you will learn how to connect an Arduino to a 16x2 LCD display. 

The JHD162A is a 16x2 LCD module based on Hitachi's HD44780 driver. The JHD162A has 16 pins and can be used in 4-bit or 8-bit mode (using only four data lines) or (using all 8 data lines) respectively. In this case, the LCD module is set to 4-bit mode.

Before going into the details of the project, let’s have a look at the JHD162A LCD module. The schematic of a JHD162A LCD pin diagram is given below.

How to Interface 16x2 LCD with Arduino Uno ?, 16x2 LCD

Pinout:

  • Pin1(Vss): Ground pin of the LCD module.
  • Pin2(Vcc): Power to LCD module (+5V supply is given to this pin)
  • Pin3(VEE): Contrast adjustment pin. This is done by connecting the ends of a 10K potentiometer to +5V and ground and then connecting the slider pin to the VEE pin. The voltage at the VEE pin defines the contrast. The normal setting is between 0.4 and 0.9V.
  • Pin4(RS): Register select pin. The JHD162A has two registers namely command register and data register. Logic HIGH at RS pin selects data register and logic LOW at RS pin selects command register. If we make the RS pin HIGH and feed an input to the data lines (DB0 to DB7), this input will be treated as data to display on the LCD screen. If we make the RS pin LOW and feed an input to the data lines, then this will be treated as a command ( a command to be written to LCD controller – like positioning cursor or clear screen or scroll).
  • Pin5(R/W): Read/Write modes. This pin is used for selecting between read and write modes. Logic HIGH at this pin activates read mode and logic LOW at this pin activates write mode.
  • Pin6(E): This pin is meant for enabling the LCD module. A HIGH to LOW signal at this pin will enable the module.
  • Pin7(DB0) to Pin14(DB7):  These are data pins. The commands and data are fed to the LCD module though these pins.
  • Pin15(Backlight +): Anode of the back light LED. When operated on 5V, a 560 ohm resistor should be connected in series to this pin. In arduino based projects the back light LED can be powered from the 3.3V source on the arduino board.
  • Pin16(Backlight -): Cathode of the back light LED.

Working

To detect whether a person is entering or exiting the room, two infrared sensors are used. When an individual enters the room, the signal from the first IR sensor bounces back, followed by the signal from the second, indicating that the motion is inward and the count is increased. When anyone leaves the room, the count is also reduced. If the count is greater than zero, the relay should be turned on; otherwise, it should be turned off.

Circuit Diagram
circuit diagram for Bidirectional Visitor Counter using IR sensor

Arduino Code
#include<LiquidCrystal.h>
LiquidCrystal lcd(13,12,11,10,9,8);
int In = 4;
int Out = 5;
int relay = 2;
int count=0;
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:");
Serial.begin(9600);
}
void loop()
{
if (digitalRead(In) == LOW){
count++;
}

else if (digitalRead(Out) == LOW){
count--;
}

else if (count > 0)
{
digitalWrite(relay, HIGH);
}

else if(count <= 0){
digitalWrite(relay, LOW);
}

lcd.setCursor(0,1);
lcd.print(count);
Serial.println(count);
delay(700);
}

 

Diy projects

2 comments

Kapil Kumar

Kapil Kumar

@Sivakumar,
That’s Great that you understood the concept. The module which is shown in black colour is the Relay module which is used as a switch in the circuit.
If you wish to read about the relay module, here is link, https://www.hnhcart.com/blogs/sensors-modules/relay-module

Sivakumar

Sivakumar

I am a beginner. I understood the concept but what is the use of this black module with this bulb?

Leave a comment

All comments are moderated before being published