Ultrasonic Sensor as a Counter with Arduino

Ultrasonic Sensor as a counter with Arduino








Hi in this tutorial we will see how to use ultrasonic sensor as a counter and output will be shown on LCD display. It will count number of times object passes in front of sensor.

Circuit Diagram

Provide separate ground for ultrasonic sensor. And connect VCC pin near to 5V pin. Otherwise it will not work and sensor will give constantly increment values even you are not doing anything with the sensor.


Code


4 Comments

  1. How to Avoid continues count???

    ReplyDelete
    Replies
    1. You can use the bouncing condition, like below:
      bounce_conition();
      /*Bounce Condition Fucntion to Stop Continues Count*/
      void bounce_conition()
      {
      while(distance <= Distance)
      {

      }
      }

      Delete
  2. This is great, works fantastic.
    Where would you include the "Bounce Condition" in the sketch?
    I am trying to make it count my setup reps during exercise, but it is counting too much.

    ReplyDelete
  3. Hi there why does my counter counts up by its own continuously. I have followed the diagram and the code as explained. Please advise Thx

    ReplyDelete