0% found this document useful (0 votes)
117 views

Ultrasound Module Mod

This document describes an ultrasound module that can measure distances between 2cm and 450cm. It works by sending out ultrasonic pulses and measuring the time it takes for the echo to return. The module connects to an Arduino via trigger and echo pins. The Arduino generates a 10us pulse on the trigger pin to start measuring. It then uses the pulseIn() function to measure the width of the return pulse on the echo pin and calculates the distance based on the speed of sound. Sample Arduino code is provided to illustrate how to use the module to obtain distance measurements and print them to the serial port.

Uploaded by

Adam Mikitzel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views

Ultrasound Module Mod

This document describes an ultrasound module that can measure distances between 2cm and 450cm. It works by sending out ultrasonic pulses and measuring the time it takes for the echo to return. The module connects to an Arduino via trigger and echo pins. The Arduino generates a 10us pulse on the trigger pin to start measuring. It then uses the pulseIn() function to measure the width of the return pulse on the echo pin and calculates the distance based on the speed of sound. Sample Arduino code is provided to illustrate how to use the module to obtain distance measurements and print them to the serial port.

Uploaded by

Adam Mikitzel
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Ultrasound Module(HC_SR04)

Summary

In this project we will use an ultrasound module to measure distance and print it out on the
Arduino serial port.

Materials
Arduino Uno x 1
HC_SR04 x 1
A number of Dupont wires

Product Description

T
his module measure distance accurately and features stable performance. Minimum distance is quite close
at 2cm.
It can be used for robot obstacle avoidance, distance measurement, liquid level measurement, public
security and parking lot detection.
Specification
Working voltage:DC 5V
Quiescent current:less than 2mA
Electrical level output:high--5V
Electrical level output:low--0V
Detection angle:less than 15 degree
Detection range:2cm-450cm
High precision:Up to 0.3cm

Operational Principle
The device is triggered by a 10μs pulse on its Trigger Input
The module automatically transmits 8x40khz square waves, and detects if any signal is returned.
If there is a signal returned, it outputs a pulse on its output channel equal in length to the time of the
ultrasound pulse from transmission to reception.
The detected distance of the object is then given by

(the period of high electrical level * speed of sound(340M/S))/2

Use Method and Sequence Diagram

To use with an Arduino, the Arduino is used to generate a 10μs pulse on the trigger pin of the SR04 to start
distance measurement.
The device will then trigger 8x40KHz ultrasonic pulses.
Use Arduino and adopt digital pin to offer at least 10μs high electrical level signal for Trig pin of SR04, to
trigger SR04 module’s distance measurement function and listen for any detected returns.
If a signal return is detected, the output pin on the SR04 will go high for the time of the detected transmission
to return. The Arduinos function pulseIn() can then be used to measure this time and used to calculate the
actual distance from the measured object.

Wiring Diagram
Sample Code
// Define the SR04 connection to the Arduino pin
const int TrigPin = 2;
const int EchoPin = 3;
float distance;
void setup()
{ // Initialization of serial communication and SR04's pins
Serial.begin(9600);
pinMode(TrigPin, OUTPUT);
pinMode(EchoPin, INPUT);
Serial.println("Ultrasonic sensor:");
}
void loop()
{
// Generate a high pulse of 10us to trigger TrigPin
digitalWrite(TrigPin, LOW);
delayMicroseconds(2);
digitalWrite(TrigPin, HIGH);
delayMicroseconds(10);
digitalWrite(TrigPin, LOW);
// Detecting the width of the pulse and calculating the distance
distance = pulseIn(EchoPin, HIGH) / 58.00;
Serial.print(distance);
Serial.print("cm");
Serial.println();
delay(1000);
}

Notes
pulseIn():Function for detecting pulse width for high and low levels measured on a pin.
pulseIn(pin, value)
pulseIn(pin, value, timeout)
Pin---the pin which need to read pulse.
Value---the type of pulse which needs to read, HIGH or LOW.
Timeout---the unit is microsecond(μs),the data type is unsigned long int.
Results

You might also like