Introduction: Count Objects Using Arduino and Ultrasonic Sensor on a Production Conveyor
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