How to Use the HC-SR04 Ultrasonic Sensor With the Arduino UNO
by TechSensor in Circuits > Arduino
13131 Views, 1 Favorites, 0 Comments
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.
Downloads
Supplies
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
Place the ultrasonic sensor on the breadboard like in the picture.
Connect Jumper Wire to Ground and to Ground
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
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
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
Connect the fourth jumper wire to the VCC pin on the sensor and to the 5V pin on the Arduino.
Connect USB Cable
Connect the USB cable with one end to the Arduino and the other end to the computer.
Open Arduino Sketch
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
Click the upload button to upload the sketch to the Arduino.
After a few seconds the upload should be complete.
Open Serial Monitor
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!