Count Objects Using Arduino and Ultrasonic Sensor on a Production Conveyor

Introduction: Count Objects Using Arduino and Ultrasonic Sensor on a Production Conveyor

About: KEA is located in the Danish capital of Copenhagen where we teach more than 9000 students in the disciplines within design and technology. These instructables are created by students as documentation of their …


This instructable explains how to use an ULTRASONIC SENSOR with Arduino to count/ log different packages on a conveyor. The instrucable will cover the physical setup and the program in Arduino.

There will NOT be any information about how to build the lasercutted conveyor that is powered by a stepper motor.

The result will a log over the counted packages in the serial monitor.

Step 1: Partlist

· Arduino UNO board

· SR04 Ultrasonic Sensor

· USB cable type A/B

· Universal 4 pin Grove Cable

Step 2: Connecting the Ultrasonic Sensor to Your Arduino Board

Use the Universal 4 pin Grove Cable to connect the Ultrasonic Sensor to your Arduino board in pin D7. Use the USB A/B cable to connect the Arduino board to your computer. The distance between the sensor and the floor is 128 mm.

Step 3: Write Your Code – or Download It From Here.

When you have uploaded the code to your Arduino you should see something similar to this when opening the serial monitor.

You can edit the intervals in the if-statement to match the objects you want to count. In the example the height of the packages is 40 mm, 53 mm and 72 mm.

Hope you enjoy!

/ Simon Larsson

Be the First to Share


    • Rice & Grains Challenge

      Rice & Grains Challenge
    • CNC and 3D Printing Contest

      CNC and 3D Printing Contest
    • Lamps Challenge

      Lamps Challenge



    Question 4 months ago on Step 1

    Hello can simulate the project on sw before installing it?
    if yes then can you please help me with simulation ckt diagram


    2 years ago

    Hello, do you have any pictures of how you wired the breadboard and the arduino? or any resources I could possibly look at?


    Question 2 years ago on Step 3

    Hello, can you tell me how you assembled the conveyor belt? what elements were used, as well as the program code.


    6 years ago

    can i use ir sensor ??