Site icon 14core.com

Wiring HC-SR04 Ultrasonic on Reverse Parking Sensor

In this illustration we will going to wire the Ultrasonic HC-SR04 with our Arduino board, to build a parking sensor which emits a beep as the sensor approaches or detect an obstacle. The closer the obstacle, the greater the frequency of the beep.

Required Components

1x Arduino UNO/MEGA/NANO/PRO
1x Ultrasonic Ranging Sensor Module HC-SR04
1x buzzer
1x Solder Less Bread Board
1x Jumper Wire
1x Resistor 330 Ohms

Wiring Diagram

This diagram composed of Arduino and HC-SR04 Ultrasonic Ranging Sensor and a Buzzer with resistance of 330 Ohms to limit the current.

The TONE, Normally used to produce sounds with Arduino, shows conflict with the library Ultrasonic also used in this project. The sound of the beep can be change as required by changing the value variable frequency and time. The pin Trigger sensor will connected to pin 13 of the Arduino and the pin Echo sensor will connected to Arduino pin 10. The sensor running at 5v. the buzzer goes on port 2 of the MCU Arduino. The variable cmMsec stores the value of the distance between the sensor and the obstacle. A series of command IF check the value cmMsec and update the variable delay which is used later in the program to determine the beeper drive frequency. The values read by the sensor can also be monitored by the serial.

Arduino Sketch
[crayon-672a85ec1cec1942747947/]
Download Code library for Tone Generator | Zip

 

Wiring HC-SR04 Ultrasonic on Reverse Parking Sensor
Exit mobile version