Ultrasound Arduino.

The Sensor HC-SR04

HC-SR04 Sensor of ultrasonic
HC-SR04 Sensor of ultrasonic for Arduino.

Operating principle of the HC-SR04

HC-SR04 is a sensor to measure distances using ultrasound, operation is simple, sends a sound below the threshold that perceives the human ear (ultrasound) and waiting to receive the echo when you receive turn signal measure the time between sent and reception and we get the distance.

Connections of the HC-SR04

The sensor has four connections:

  • Power supply: 5V
  • Send Pulse: Tigger press Input
  • Receive echo: Echo press Ouput
  • Mass: GND

Characteristics of the HC-SR04 ultrasonic sensor

Work voltage 5V DC
Consumption 15mA
Frequency 40 Hz
Range maximum 4m
Minimum range 2cm
Measurement angle 15.
Trigger input signal 10uS TTL pulse
Echo return Input TTL proportional to the input
Dimensions 45 * 20 * 15 mm

Connection power of the Sensor with Arduino

Example Breadboard ultrasonic Sensor and Arduino

 

Arduino + ultrasound
Prototyping of an Arduino with an ultrasonic sensor.

Wiring diagram of the ultrasonic sensor for Arduino

Wiring diagram HC-SR04
Connection diagram for the HC-SR04 with Arduino

Program in Arduino

Explanation prior to the programming of the HC-SR04

The sensor of ultrasonic HC-SR04 need that was you sent a signal of 5v from the Arduino by Trig, in our scheme connected to the pin 9. Once sent hope the answer pulseIn() and thereby obtain the response time. The distance is optiene of a constant times the time.

Code

long distance;
long time;

void setup() {}
  Serial.begin (9600);
  pinMode (9, OUTPUT); / * activation of the 9 pin as output: for ultrasonic pulse * /
  pinMode (8, INPUT); / * the 8 pin as input activation: ultrasound bounce time * /
}

void loop() {}
  digitalWrite (9, LOW); / * Point of sensor stabilization * /
  delayMicroseconds (5);
  digitalWrite (9, HIGH); / * sending of ultrasonic pulse * /
  delayMicroseconds (10);
  time = pulseIn HIGH (8); / * Function to measure the length of the incoming pulse. Measures the time that elapsed between the sending
  the ultrasonic pulse and when the sensor receives the rebound, i.e.: since the 12 pin starts to receive the rebound, HIGH, until
  Let's do it, LOW, the length of the pulse incoming * /
  distance = int(0.017*tiempo); / * formula to calculate the distance getting an integer * /
  / * Centimeters by the serial monitor monitoring * /
  Serial.println ("distance");
  Serial.println (distance);
  Serial.println("cm");
  delay (1000);
}

Once programmed and compiled the Arduino we will see distances to which an obstacle of our sensor is located by the serial monitor.

Acquire the Sensor of proximity

If need a Sensor of proximity for your project can access to our section of products for purchase that best you agree, different prices and vendors. Or click here to go directly to search an ultrasonic sensor.

Buy ultrasound for Arduino
Buy ultrasound for Arduino

Example video

If want to make things more complicated and need help I offer as freelance for development with Arduino and similar.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.