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);
  }
}



Dr. Dattaraj Vidyasagar
Dr. Dattaraj Vidyasagar

M.S. Electronics & Telecomm. (Cleveland Institute of Electronics, Ohio), Associate Member (IETE, Kolkata), Panelist on Dr. Homi Bhabha Foundation, Google certified educator (Level-1), Mentor of Change (MoC-1619) Niti Ayog, Government of India, International Robotics Trainer, Veteran of Applied Electronics since 35+ years.

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