Visitor counter project using Arduino

visitor-counter-project-using-arduino

People  or Visitor counters are pretty famous embedded application that was widely used in places like theaters, malls, Transport stations and so. High end counters uses sophisticated hardware to do the process of counting. Today we are about to see building of simple Visitor counter project using Arduino which uses IR as a tool for sensing people. This project can also be used to count objects as well provided that the surface of the object capable of reflecting IR signal.

PARTS REQUIRED:

  1. Arduino Uno
  2. IR sensor Module
  3. LCD display
  4. Connecting Wires

IR SENSOR MODULE:

IR-infra-red-sensor-module

IR sensor module uses IR signal to detect the people entering through a pathway or entrance. This was done by sending a Pulse of IR signal from IR LED and detecting the reflected signal by using a photodiode. The IR signal will get only reflected back when there is a people or object going through that path. The module you are seeing above is bought from a local merchant and gives out high logic 1 when reflected signal is detected. You can buy from any online store or make one on your own, this tutorial “Making your own IR sensor” might help you.

DESIGN:

people-counter-schematic-design

Take a look at the given design of Visitor counter project using Arduino. Here the IR sensor output was connected to the external interrupt pin 2 of the Arduino. So whenever the sensor gives output high Arduino increases the count by 1. A 16×2 LCD was used as a display here for the number of visitor counts. A pull down resistor was used to keep the output low when there is no people encountered by the sensor.

ALGORITHM TO CODE:

  1. Initialize LCD display to print your data.
  2. Set up external interrupt on either pin 2 or 3 of the arduino with suited mode for your sensor.
  3. Write the ISR routine to increase the count by 1 whenever an interrupt is encountered.
  4. Display the count value in the LCD for the user.

CODE:

#include <LiquidCrystal.h>

LiquidCrystal lcd(8, 7, 6, 5, 4, 3);
unsigned int count=0; 
char converted_value[6];

void setup() {
  lcd.begin(16, 2);
  lcd.print("Number of People:");
  attachInterrupt(digitalPinToInterrupt(2), counter,HIGH);  //Initializing external interrupt
}

void loop() 
{
  lcd.setCursor(0,1);
  lcd.print(converted_value);             //Printing count values
}

void counter()
{
  count++;                              //Incrementing visitor count
  sprintf(converted_value,"%d",count);  //int to char conversion
}

 NOTE:

  • Make sure to understand all the specs of sensor if you are going to buy, since they might vary in their output ( active low or active high).
  • Make sure to allow people or objects to pass through within the range of the sensor.
  • Also only certain objects reflect IR signals back, make sure your object does if you are about to use this project to count objects.

 


32 Comments

  1. mica

    Hello! My LCD didn’t display any of the increment. Can you help me with this?

    Reply
  2. maxwell

    Hi i’m maxwell im doing a project on bidirectional visitor countre using arduino and pir seensor, my problm is that the code is not working perfectly.. so please can some one help me wich the code using pir sensor? please i need help.

    Reply
    1. Frank DonaldFrank Donald (Post author)

      Hi Maxwell,
      What problem you are facing, please brief it up. I might be able to help you then

      Reply
      1. Anonymous

        Hi Donald
        my problem is that the decrement is counting up to the negative side inside of to stop at zero. So please if you can help me with the code… thanks

        Reply
  3. ivan

    how to add GSM ? any idea pls.

    Reply
    1. Frank DonaldFrank Donald (Post author)

      Hi Ivan,
      Can you brief up why do you want GSM to add in this project?

      Reply
  4. Eman

    hello sir!
    can you plz give me algo code in assembly language??

    Reply
    1. Frank DonaldFrank Donald (Post author)

      Hi Eman,

      Apologies, Am not sure about that.

      Reply
  5. Vijay

    Can I use Arduino Mega2560 instead of Arduino UNO?

    Reply
    1. Frank DonaldFrank Donald (Post author)

      Vijay,
      I believe you can. But change the pins used accordingly

      Reply
  6. ebrahim

    hey bro i completed it but the increment is of 2 instead of 1

    Reply
    1. Frank DonaldFrank Donald (Post author)

      Ebrahim,

      Run a quick check on your IR sensor i believe it might create a false trigger thus increasing the count by 2 instead of 1. Try changing IR sensor as well.

      Reply
      1. ebrahim

        i got two ir sensor i checked both nut in both case it is incrimenting by 2

        Reply
  7. ebrahim

    What is that silver thing connected beside the lcd

    Reply
    1. Frank DonaldFrank Donald (Post author)

      Ebrahim,

      It was the pins of LCD.

      Reply
      1. Mark

        sir what is the extension for that code?

        Reply
        1. Frank DonaldFrank Donald (Post author)

          Mark,
          Use this code with Arduino IDE. I didn’t upload the .ino file. You can copy this code to a notepad and rename its as example.ino and use it

          Reply
          1. anvar

            where is the code.

  8. ADRIAN

    I cant find the sensor in my library,any help please.

    Reply
  9. Hala

    How can I make this circuit count the number of people entering to the gate and who are exiting from that gate? can I use pair of IR sensor module?

    Reply
    1. Frank DonaldFrank Donald (Post author)

      Hala,
      It’s simple add a IR sensor module to the exit door of your room. Count the number of people entering and exiting the room and keep it in separate variables. If you need to know the number of people in the room then Number of people entered – number of people exited

      Reply
  10. Hala

    How can I make this circuit to add number of people entering and minus the number of who exiting from that gate?

    Reply
    1. Swapnil

      when you take two different variables ie. for the people that enter and the people that leave so when you code to show to outpute that x are in and y are out
      so instead of that put x-y in the output

      Reply
      1. Frank DonaldFrank Donald (Post author)

        Hi Hala,
        Swanpil suggestion will meet your need.

        Swanpil,
        Thanks for your suggestion cheers 🙂

        Reply

Leave a Comment

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