Also read!
Home / Tools / Arduino / Ultrasonic sensor HC-SR04 for Arduino

Ultrasonic sensor HC-SR04 for Arduino

For those not familiar with Arduino, is an open source platform to simplify the development and teaching of microprocessors. This is a very common sensor, the Ultrasonic sensor HC-SR04, measuring distances between 2 the 450cm.

556e54c72bd3e_IMG_20150531_170535

Below the back of the label. On the front we have the transmitter and receiver of ultrasound. To use the Arduino must download the library This link. If you want to take a look at the datasheet, can follow This link.

The sensor works by sending a sound wave (Ultrasound), that rebate in an obstacle and is received back by label. The time it takes for the sound to be received again upon reflection can be used to calculate the distance to the obstacle.

556e54ca4044a_IMG_20150531_170600

Now we have, in the picture below, the sensor is connected to a Arduino UNO. Should VDC and GND connect the sensor to the VCC and GND of the Arduino and Trigger pins and Echo to the pins 12 and 13. If you want to change the place of connection of Trigger pins and echo, can, in the sample program, look for the line:

Ultrasonic ultrasonic(12,13);

In this case, the pins 12 and 13 are trigger and echo, respectively. Just change the code to connect the other pins.

556e54b96ea8e_IMG_20150530_181927

The sample program measures the distance, in cm, in front of the sensor, and sends the serial port (USB).

556e54c10c0f1_IMG_20150530_181933

A simpler programme measures only the ultrasound return time.

556e54c5122f2_IMG_20150530_182112

Very good and cheap! Really liked it. I leave the link to the sensor and to the Arduino UNO:

Ultrasound Sensor – http://www.dx.com/pt/p/hc-sr04-ultrasonic sensor-distance-measuring-module-133,696

Arduino UNO – http://www.dx.com/pt/p/dccduino-atmega328-development-board-for-arduino-uno-r3-blue-340,374

About Adriano

Professor, Engineer and buyer of products crazy China.

2 comments

  1. Have you tried the RF modules? It seemed too simple use the USART.

Leave a Reply to Adriano Moutinho Cancel reply

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

*