kblox Neo+ Robotics Kit
About Lesson

Visitor Counter Project

Introduction

People or Visitor counters are pretty famous embedded applications that are widely used in places like theaters, malls, Transport stations and so. High-end counters use sophisticated hardware to do the process of counting. Here you will make a simple Visitor counter project using the Novation DIY board which uses IR as a tool for sensing people.

A visitor counter using Kblox Neo is a reliable circuit that takes over the task of counting a number of Persons/ Visitors in the Room very accurately. if somebody enters into the Room then the Counter is incremented by one and also leaves it would be incremented.

The total number of persons inside the room is shown on the 16X2 LCD module. There are two IR Modules used. First, one is used to count the number of persons entering a hall. And the second one can count the number of persons leaving the hall. The LCD will show the total number of people present in the hall.

 

Components Required

  • Kblox Neo
  • IR sensor [Qty-2]
  • LCD (16×2)
  • Breadboard
  • Resistors 1K [Qty-1]
  • Jumper wires

Code

#include "kblox.h"

kblox kit;
kblox_lcd lcd(12, 11, 6, 5, 3, 2);   //Define lcd pins

int count = 0;                           // create count variable
void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);                  // initialize serial monitor
  lcd.begin(16, 2);                    // initialize lcd
  lcd.print("Visitor Counter");        // print on lcd
  delay(2000);
  lcd.clear();
  lcd.print("person in room");
  lcd.setCursor(0, 1);
  lcd.print(count);
  kit.ir_begin(9, 10);     // define ir sensor pins


}

void IN() {               // function for increasing the count 

  count ++;
  lcd.clear();
  lcd.print("person in room");
  lcd.setCursor(0, 1);
  lcd.print(count);
  delay(1000);
}


void OUT() {         // function for decreasing the count

  count --;
  lcd.clear();
  lcd.print("person in room");
  lcd.setCursor(0, 1);
  lcd.print(count);
  delay(1000);
}

void loop() {

  int in = kit.ir1_read();    //store ir1 data in variable 
  int out = kit.ir2_read();   // store ir2 data in another variable 

  if (in == HIGH)            // if someone entered in the room incrase the count 
  {
    IN();
  }
  if (out == HIGH)          // if someone left the room decrease the count 
  {
    OUT();
  }


}