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 IDE. 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!
Prof. Dattaraj Vidyasagar
Prof. 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... ➤➤

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x