Simple circuit of object counter using Arduino

This circuit can count number of persons entering a premise or number of objects passing in front of an IR sensor. The code works very nicely and fully tested in our lab.

Note that a buzzer for short beeps is connected at pin-2 and the IR sensor is connected at pin-5. The delay in second “if” conditional statement is used to avoid accidental triggering of the sensor.

You can check the output of the counter on SERIAL MONITOR of Arduino IDEWhat is Arduino IDE? Arduino IDE stands for Integrated Development Environment. It is also called as Arduino software in general language or Arduino compiler. It is used to convert high level programming language like C/C++ program into machine code i.e. into low level language.. First burn the code in your Arduino kit and then click on “Tools” menu in Arduino IDE and then click Serial Monitor to check the output of the counter.

The Code

/*
 * Object counter using Arduino 
 * Code designed by Vidyasagar Academy
 * www.vsa.edu.in
 */
 
int counter=0; // variable to count the objects

void setup()
{
  Serial.begin(9600);
  pinMode(1,OUTPUT); // buzzer at pin-1
  pinMode(5,INPUT); // IR sensor at pin-5
}

void loop()
{
  if(digitalRead(5)==HIGH)
  {
    digitalWrite(1,LOW);
  }

  if(digitalRead(5)==LOW)
  {
    digitalWrite(1,HIGH);
    counter++;
    delay(100);
    digitalWrite(1,LOW);
    Serial.print("Total Objects: ");
    Serial.println(counter);
    delay(1000);
  }
}



Share on your network!
Dattaraj Vidyasagar
Dattaraj Vidyasagar

Author on this website. He is veteran of Core Electronics since last 36+ years. ATL Mentor of Change, Niti Ayog, Govt. of India, Google Certified Educator, International Robotics Trainer and author of 18 books on electronics, robotics, programming languages and web designing... ➤➤

Leave a Reply

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