Introduction to Ultrasonic Radar:
The functionality of Arduino is truly powerful, allowing for the creation of interesting projects using various sensors. Today, we will develop an ultrasonic radar using the Arduino board and ultrasonic sensor, capable of detecting distances up to 40CM. When there are obstacles, the scanning interface will display red and show the range and distance.
Components List
1. Arduino Development Board
2. Ultrasonic Sensor (HC-SR04)
3. Servo (SG90)
4. Wires
Sensor Introduction
1. Ultrasonic Sensor
Main Technical Parameters
1. Operating Voltage: DC—5V
2. Static Current: Less than 2mA
3. Output Level: High 5V
4. Output Level: Low 0V
5. Sensing Angle: No more than 15 degrees
6. Detection Range: 2cm-450cm
7. High Precision: Up to 0.2cm
8. Connection Method: VCC, trig (control terminal),
echo (receiving terminal), GND
Module Features
The HC-SR04 ultrasonic distance measuring module has precise distance measurement capabilities, comparable to SRF05, SRF02, etc. The measuring distance is ** 2cm~450cm (actual measurement: 10cm~300cm). Working Principle: 1) Use IO to trigger distance measurement, sending a high-level signal of at least 10us. 2) The module automatically sends 8 pulses of 40KHz square wave and detects if there is a returning signal. 3) If a signal returns, it outputs a high level through IO, and the duration of the high level is the time taken for the ultrasonic wave to travel from transmission to return. Just provide a pulse trigger signal of more than 10uS, and the module will emit 8 cycles of 40kHz and detect the echo. Once an echo signal is detected, it outputs a reflection signal. The pulse width of the reflection signal is proportional to the measured distance. Thus, the distance can be calculated from the time interval between the transmitted signal and the received echo signal. Formula: uS/58=cm or uS/148=inches; or: Distance = high-level time * speed of sound (340M/S) /2; It is recommended that the measurement cycle be more than 60ms to prevent the transmission signal from affecting the echo signal.
Note:
1. This module should not be connected under power; if it must be connected under power, connect the GND terminal first, otherwise, it will affect the normal operation of the module.
2. When measuring distance, the area of the object being measured should be at least 0.5 square meters and as flat as possible; otherwise, it will affect the measurement results.
2. Servo
Servo: It is an automatic control system composed of a DC motor, a reduction gear set, sensors, and control circuits. By sending signals, it specifies the rotation angle of the output shaft. Generally, servos have a maximum rotation angle (e.g., 180 degrees). The main difference from ordinary DC motors is that DC motors rotate continuously, while servos can only rotate within a certain angle and cannot rotate continuously (digital servos can switch between servo mode and motor mode, avoiding this issue). Ordinary DC motors cannot feedback rotation angle information, while servos can. Their uses are also different; ordinary DC motors are generally used for continuous rotation, while servos are used to control the rotation of an object at a specific angle (e.g., the joints of a robot).
Hardware Circuit
Precautions:
1. Do not reverse the positive and negative connections of the ultrasonic sensor module and servo.
2. Connect the servo’s PWM to Arduino pin 12.
3. Connect the ultrasonic sensor module:
trig (control terminal) to Arduino pin 2.
echo (receiving terminal) to Arduino pin 3.
Software Section
1. Required Software:
1. Arduino IDE
2. Processing (Download link: )
2. Uploading Arduino Program
We won’t go into detail about how to upload the Arduino program; there are many tutorials online that you can refer to. If you really can’t do it, feel free to leave a message.
Program code download link:
3. Open Processing
If the screen is blank, switch to the editor, click the stop button in the upper left corner. At this point, an error message will generally be given in the red bar below, modify according to the error message (usually caused by serial port errors).
Ways to Obtain the Above Programs and Software:
1. Scan the QR code to follow the public account: Smart Link Electronics DIY
2. Reply to the keyword in the public account: Ultrasonic Radar
1

Follow the Smart Link Electronics DIY public account for more electronic production, electronic circuit information, microcontroller, Arduino, ESP, Raspberry Pi, and more resources and learning methods
1

For previous materials, click the lower left corner on “Read More“