The HC-SR04 Ultrasonic Distance Sensor was developed to perfect robotics and electronics projects, it is ideal for accurately calculating the distance of objects. This module has a ready-made circuit with emitter and receiver coupled and 4 pins (VCC, Trigger, ECHO, GND) for the measurement.
The HC-SR04 is a Distance Sensor consisting of an emitter and a receiver, capable of measuring distances from ~2cm to ~4m, with an accuracy of approximately 3mm. This sensor emits ultrasonic signals that reflect off the object to be hit and return to the sensor, indicating the distance from the target.
The speed of the ultrasonic signal emitted by the Sensor HC-SR04 It corresponds to the speed of sound, which is approximately 340 m/s, so if the sensor is at x distance from the object, the signal will travel a distance equivalent to 2x, that is, the wave is sent by the sensor and bounced off the obstacle, so it travels 2 times the distance sought.
For better organization, you can attach this sensor to this distance sensor holder, making it easier to prototype your project.
Characteristics:
• Power supply: 5V DC;
• Operating Current: 2mA;
• Angle of effect: 15°;
• Range.: 2cm~4m;
• Accuracy.: 3mm;
• Connection modes: VCC, trig (T), echo (R) and GND;
• Ideal for use on Arduino, PIC and other microcontrollers;
• Datasheet SGM324.
Use:
Sample Code:
Library used: https://github.com/ErickSimoes/Ultrasonic
Program: Connect the HC-SR04 Ultrasonic Sensor to the Arduino
Loads the ultrasonic sensor library
<#include Ultrasonic.h>
Sets the pins for the trigger and echo
#define pino_trigger 4
#define pino_echo 5
Initializes the sensor to the pins defined above
Ultrasonic ultrasonic(pino_trigger, pino_echo);
void setup()
{
Serial.begin(9600);
Serial.println(“Reading sensor data…”);
}
void loop()
{
Reads sensor information, in cm and in.
float cmMsec, inMsec;
cmMsec = ultrasonic.distanceRead(CM);
inMsec = ultrasonic.distanceRead(INC);
Displays information on the serial monitor
Serial.print(“Distance in cm: “);
Serial.print(cmMsec);
Serial.print(” – Distance in inches: “);
Serial.println(inMsec);
delay(1000);
}
Reviews
Clear filtersThere are no reviews yet.