How to Use the HC-SR04 Ultrasonic Sensor With the Arduino UNO

by TechSensor in Circuits > Arduino

9108 Views, 1 Favorites, 0 Comments

How to Use the HC-SR04 Ultrasonic Sensor With the Arduino UNO

How To Use the HC-SR04 Ultrasonic Sensor With the Arduino UNO

In this tutorial you will learn how to use the HC-SR04 Ultrasonic Sensor with the Arduino UNO R3.

Supplies

parts_list.png

You will need:

  • 1x Computer with Arduino IDE installed
  • 1x Arduino UNO R3 or clone
  • 1x USB Cable
  • 1x Breadboard
  • 1x HC-SR04 Ultrasonic Sensor
  • 4x Male to Male Jumper Wires

Place Ultrasonic Sensor on Breadboard

step_1.png

Place the ultrasonic sensor on the breadboard like in the picture.

Connect Jumper Wire to Ground and to Ground

step_2.png

Connect the first jumper wire to the ground on the sensor and to the ground on the Arduino.

Connect Jumper Wire to Echo and to Pin 10

step_3.png

Connect the second jumper wire to the echo pin on the sensor and to pin number 10 on the Arduino.

Connect Jumper Wire to Trigger Pin and to Pin 9

step_4.png

Connect the third jumper wire to the trigger (TRIG) pin on the sensor and to pin number 9 on the Arduino.

Connect Jumper Wire to VCC and to 5V

step_5.png

Connect the fourth jumper wire to the VCC pin on the sensor and to the 5V pin on the Arduino.

Connect USB Cable

step_6.png

Connect the USB cable with one end to the Arduino and the other end to the computer.

Open Arduino Sketch

step_7.png

Download and open the Arduino sketch, you can download it at the beginning of this page.

Then open it with the Arduino IDE.

Upload Sketch to Arduino

step_8.png

Click the upload button to upload the sketch to the Arduino.

After a few seconds the upload should be complete.

Open Serial Monitor

step_9.png

Click the button in the top-right corner of the Arduino IDE to open the Serial Monitor.

Here you can see communications between the Arduino and the computer.

You should see the distance the ultrasonic sensor is measuring in centimeter.

Congratulations on completing this tutorial!