Introduction: Ultrasonic Sensor Tutorial Using Arduino
This instructable is a guide about the popular Ultrasonic Sensor HC – SR04. I’ll explain how it works, show you some of its features and share an Arduino project example you can follow to integrate in your projects. We provide a schematic diagram on how to wire the ultrasonic sensor, and an example sketch to use with the Arduino.
- Arduino UNO or any other Arduino Board
- HC-SR04 Ultrasonic Sensor
- Jumper Wires
Step 1: Description
The HC-SR04 ultrasonic sensor uses sonar to determine distance to an object like bats do. It offers excellent non-contact range detection with high accuracy and stable readings in an easy-to-use package. It comes complete with ultrasonic transmitter and receiver modules.
Step 2: Features
Here’s a list of some of the HC-SR04 ultrasonic sensor features and specs:
- Power Supply :+5V DCQuiescent
- Current : <2mA
- Working Current: 15mA
- Effectual Angle: <15°
- Ranging Distance : 2cm – 400 cm/1″ – 13ft
- Resolution : 0.3 cm
- Measuring Angle: 30 degree
- Trigger Input Pulse width: 10uS
- Dimension: 45mm x 20mm x 15mm
Step 3: Working
The ultrasonic sensor uses sonar to determine the distance to an object. The transmitter (trig pin) sends a signal a high-frequency sound. When the signal finds an object, it is reflected and…… the transmitter (echo pin) receives it. The time between the transmission and reception of the signal allows us to calculate the distance to an object. This is possible because we know the sound’s velocity in the air.
Step 4: Interfacing Ultrasonic Sensor With an Arduino
This sensor is very popular among the Arduino tinkerers. So, here we provide an example on how to use the HC-SR04 ultrasonic sensor with the Arduino. In this project the ultrasonic sensor reads and writes the distance to an object in the serial monitor.
The goal of this project is to help you understand how this sensor works. Then, you should be able to use this example in your own projects.
Step 5: Schematics
Follow the schematic diagram to wire the HC-SR04 ultrasonic sensor to the Arduino.
Step 6: Code
Upload the given code to Arduino using Arduino IDE