Arduino Distance Detector
This simple guide teaches how to make a distance detector using an Arduino, ultrasonic sensor, buzzer, and LED lights. The ultimate goal of this tutorial is to use the buzzer and LED's to display the distance between the object and ultrasonic sensor.
Project inspired by: https://www.instructables.com/Arduino-Distance-Det...
I improved the product by increasing the volume of the buzzer so that it it easier to hear.
Supplies
Circuiting:
- 1x Arduino Uno
- 1x Breadboard
- 1x HC-SRO4 Ultrasonic Sensor
- 1x Buzzer - 6x LEDs
- 7x 330 OHM Resistors
- Many Jumper Wires
Outside;
- 1x Cardboard Box/Pieces
- Paper (Optional) -
Scissors
- Tape
Setup
- 5 volt pin on the Arduino -> bottom channel of the breadboard.
- Ground pin on the Arduino -> upper channel of the breadboard.
Buzzer -> pin 3
(On Ultrasonic Sensor)
Echo -> pin 6
Trig -> pin 7
(In Order from Right to Left)
LED1 -> pin 8
LED2 -> pin 9
LED3 -> pin 10
LED4 -> pin 11
LED5 -> pin 12
LED6 -> pin 13
Breadboard
- connect the 5 volt and ground pin to the breadboard
reminder:
- the wire attached to the 5 volt pin -> the bottom channel of the breadboard
- the wire attached to the ground pin -> the upper channel of the breadboard
Ultrasonic Sensor
- place the ultrasonic sensor as far right to the breadboard as possible
- ground pin on the ultrasonic sensor -> ground channel on the breadboard
- Echo pin on the sensor -> pin 6 on the Arduino
- Trig pin on the sensor -> pin 7 on the Arduino
- VCC pin on the sensor -> 5 volt channel on the breadboard
LEDs
- longer leg (anode) -> a pin on the Arduino (with a jumper wire)
- shorter leg (cathode) -> the ground channel on the breadboard using a 330 ohm resistor
- repeat for all six of the LEDs
- last LED all the way on the left should have its anode -> pin 13 on the Arduino.
Buzzer
- attach longer leg of the buzzer -> pin 3 of Arduino and
- attach shorter leg of buzzer -> ground channel of breadboard
The Code
Copy and paste, and then upload this code into the Arduino APP. Then connect it to your Arduino board. The LEDs should progressively light up in order, and the closer your hand/object nears, the higher tone the buzzer will produce.
Outside
1. find a cardboard box
2. cut off the flaps
3. tape paper over the box (optional)
4. cut two holes on the right sides, looking at it (one on each side)
5. place the setup inside the box with the computer attachment wire coming out of one hole, and the ultrasonic sensor at the other hole