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.
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.
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.
#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 }