Arduino Sonar Object Counter With Sound
by ILoveNarutoandArduino in Circuits > Arduino
518 Views, 0 Favorites, 0 Comments
Arduino Sonar Object Counter With Sound
This tutorial will explain how to make a sonar object counter using the Arduino. This work is not original, the original project is available at ( https://www.instructables.com/Arduino-Sonar-Object-Counter/ ). I added a speaker in the machine, and when the sensor detected objects going through, it will make a noise to notify users, so users can know if something is detected without needing to look at the LCD monitor and only look at it when they want to know the number of objects counted, similar to the clerks at supermarket scanning goods.
Supplies
1. Arduino Leonardo board (or similar board)
2. Breadboard
3. Wire
4. LCD Display (I2C)
5. Sonar HC-SR04
6. Arduino Speaker
Connecting the Circuits (Power Supply & Ultrasonic Sensor )
1. Plug the power supply from 5V to the positive poles and GND to the negative poles so we can use connect the power supply easier. (Picture 1)
2. Connect the Ultrasonic Sensor (VCC to positive pole, Trig to pin 7, Echo to pin 8, GND to negative pole) (Picture 2)
3. Picture 3 shows what it should look like if connected correctly
Connect the Circuits (LCD Board)
1. Connect Four lines on the I2C LCD board (Picture 1)
2. Connect SDA and SCL on the LCD board to SDA and SDL pin on the Arduino Board (Picture 2)
3. Connect VCC to the positive pole and GND to the negative pole (Picture 3)
Connect the Circuits (speaker)
Connect the red line on the speaker to Pin 11 (or other pins that work but needs to change the code accordingly), and connect the black line to the negative pole
The Code
Before compiling and uploading the code, you will need to download the liquid crystal I2C library from this link (https://github.com/fmalpartida/New-LiquidCrystal) for the mandatory functions of I2C LCD boards.
The code is available at the link below
https://create.arduino.cc/editor/derickkk/892f4be5-69b7-41dc-861c-5e961680a7e0/preview
I added a line of code at line 58 so that when there is an object detected, the speaker will make noises to notify the user. Also, I changed from 0x3F to 0x27 at line 9 so my LCD Board can function correctly with the object counting numbers on it.
Decorate Your Machine
Cut a cardboard box and make it into a cover for the machine, remember to cut a hole for the ultrasonic sensor to work, and also save a spot for the LCD board to show without needing the user to open the cover.