top of page

Visitor Counter with Automatic light Control using IR sensor

Updated: Dec 29, 2022

In this project, we will make a Arduino based Visitor Counter with an Automatic Light Control System using Infrared sensor. The pair of IR sensors can detect the visitor IN/OUT directions and display presence of Visitor inside the building or store. The device counts the total number of people presence and automatic light. When no people are inside the room, i.e. the total number of people presence is zero then the room light is turned off.

Circuit Diagram

Components Required

Arduino Uno - 1 no

LCD16x2 I²C - 1no

Obstacle Avoidance IR sensor Module - 2 nos

Relay 1 channel - 1 no

Infrared Obstacle Avoidance IR Sensor Module

The IR sensor module consists mainly of the IR Transmitter and Receiver, Opamp, Variable Resistor (Trimmer pot), output LED in brief.

IR LED Transmitter

IR LED emits light, in the range of Infrared frequency. IR light is invisible to us as its wavelength (700nm – 1mm) is much higher than the visible light range. IR LEDs have light emitting angle of approx. 20-60 degree and range of approx. few centimeters to several feet's, it depends upon the type of IR transmitter and the manufacturer. Some transmitters have the range in kilometers. IR LED white or transparent in colour, so it can give out amount of maximum light.

Photodiode Receiver

Photodiode acts as the IR receiver as its conducts when light falls on it. Photodiode is a semiconductor which has a P-N junction, operated in Reverse Bias, means it start conducting the current in reverse direction when Light falls on it, and the amount of current flow is proportional to the amount of Light. This property makes it useful for IR detection. Photodiode looks like a LED, with a black colour coating on its outer side, Black colour absorbs the highest amount of light.

LM358 Opamp

LM358 is an Operational Amplifier (Op-Amp) is used as voltage comparator in the IR sensor. the comparator will compare the threshold voltage set using the preset (pin2) and the photodiode’s series resistor voltage (pin3).

Photodiode’s series resistor voltage drop > Threshold voltage = Opamp output is High

Photodiode’s series resistor voltage drop < Threshold voltage = Opamp output is Low

When Opamp's output is high the LED at the Opamp output terminal turns ON (Indicating the detection of Object).

Variable Resistor(Preset POT)

The variable resistor used here is a preset. It is used to calibrate the distance range at which object should be detected.

How to Use IR Sensor Module?

The 5 VDC supply input is given to the VCC pin and the supply negative is connected to the GND terminal of the module. When no object is detected within the range of the IR receiver, the output LED remains off.

When a object is detected within the range of the IR sensor the LED glows.


  • Obstacle Detection

  • Industrial safety devices

  • Wheel encoder

Pin Configuration

Pin Name Description

VCC Power Supply Input

GND Power Supply Ground

OUT Active High Output

IR Sensor Module Features

  • 5VDC Operating voltage

  • I/O pins are 5V and 3.3V compliant

  • Range: Up to 20cm

  • Adjustable Sensing range

  • Built-in Ambient Light Sensor

  • 20mA supply current

  • Mounting hole

Installing the Arduino Library

LiquidCrystal_I2C.h : you need to Download and install the LiquidCrystal_I2C library.

Follow the next steps to install those libraries.

In your Arduino IDE, to install the libraries go to Sketch > Include Library > Add .ZIP library… and select the library you’ve just downloaded.

After installing the required libraries, copy the following code to your Arduino IDE.

Subscribe and Download code.

After a successful upload, open the Serial Monitor at a baud rate of 9600. Press the “EN/RST” button on the Arduino Uno board and Open Serial monitor and see the result in Serial monitor.


bottom of page