B7: Object Counter using Serial Monitor

AR-B7: Object Counter using Serial Monitor

This entry is part 7 of 13 in the series Arduino Basic Circuits

This code is used count the number of objects passing in front of the IR sensor. It displays the count of the object on serial monitor in Arduino IDE software.

Required Material

Arduino UNO Board – 1, data cable – 1, IR Sensor – 1, Jumper wires – 3.

Working

After uploading the code in Arduino UNO board, place your palm near the IR sensor. The count of the counter will increase by “1”. With this circuit, we can count the number of objects passing in front of IR Sensor.

The Code

This code gives you the ability to count the number of objects moving on a conveyer belt or number of persons passing through a door.

Just upload the following code in Arduino UNO and test the circuit.

int irs = 7; 
int counter = 0;

void setup()
{
  Serial.begin(9600);
  pinMode(irs,INPUT);
}

void loop()
{
  while(digitalRead(irs)==LOW)
  {
    counter++;
    Serial.print("Count: ");
    Serial.println(counter);
    delay(2000);
  }
}


Procedure & Precautions

  1. After uploading the code, construct the circuit as given below.
  2. Then open Serial Monitor.
  3. Then bring your palm in front of the IR LED & Photo Diode and remove your palm.
  4. The serial monitor will show the count every time you place your hand near the IR Sensor.
  5. In this way, the circuit can count the number of objects passing in front of the IR Sensor.

Circuit Diagram

B7: Object Counter using Serial Monitor
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