![](https://electroboat.in/uploads/media/2024/15569-Ultrasonic_Distance_Sensor_-_HC-SR04-01a-1.jpg)
![](https://electroboat.in/media/image?path=uploads/media/2024/7.jpg&width=620&quality=80)
![](https://electroboat.in/media/image?path=uploads/media/2024/612VzpvhpjL__AC_UF1000,1000_QL80_.jpg&width=620&quality=80)
![](https://electroboat.in/media/image?path=uploads/media/2024/15569-Ultrasonic_Distance_Sensor_-_HC-SR04-01a-1.jpg&width=175&quality=80)
![](https://electroboat.in/media/image?path=uploads/media/2024/7.jpg&width=172&quality=80)
![](https://electroboat.in/media/image?path=uploads/media/2024/612VzpvhpjL__AC_UF1000,1000_QL80_.jpg&width=172&quality=80)
![](https://electroboat.in/media/image?path=uploads/media/2024/15569-Ultrasonic_Distance_Sensor_-_HC-SR04-01a-1.jpg&width=300&quality=80)
![](https://electroboat.in/media/image?path=uploads/media/2024/7.jpg&width=300&quality=80)
![](https://electroboat.in/media/image?path=uploads/media/2024/612VzpvhpjL__AC_UF1000,1000_QL80_.jpg&width=300&quality=80)
HC-SR04-Ultrasonic Range Finder
An ultrasonic sensor is an instrument that measures the distance to an object using ultrasonic sound waves. An ultrasonic sensor uses a transducer to send and receive ultrasonic pulses that relay back information about an object's proximity.
₹ 57 ₹99
99
Add FAQ
Connecting an HC-SR04 ultrasonic distance sensor with an Arduino is a straightforward process. The HC-SR04 sensor uses ultrasonic waves to measure distance, making it useful for applications such as obstacle detection, distance measurement, and robotics. Here’s a step-by-step guide on how to connect and use the HC-SR04 sensor with an Arduino:
Components Needed:
- Arduino board (e.g., Arduino Uno)
- HC-SR04 ultrasonic sensor
- Breadboard
- Jumper wires (male-to-male)
HC-SR04 Pinout:
The HC-SR04 sensor typically has four pins:
- VCC: Connects to Arduino 5V (or 3.3V if specified in the sensor's datasheet).
- Trig (Trigger): This pin is used to trigger the sensor to send out an ultrasonic pulse. Connect to a digital output pin on the Arduino (e.g., pin 7).
- Echo: This pin receives the ultrasonic pulse reflected back from an object. Connect to a digital input pin on the Arduino (e.g., pin 6).
- GND: Connects to Arduino ground (GND).
Wiring Instructions:
-
Power Connections:
- Connect the VCC pin of the HC-SR04 to the 5V pin on the Arduino.
- Connect the GND pin of the HC-SR04 to the GND pin on the Arduino.
-
Trigger and Echo Connections:
- Connect the Trig pin of the HC-SR04 to a digital output pin on the Arduino (e.g., pin 7).
- Connect the Echo pin of the HC-SR04 to a digital input pin on the Arduino (e.g., pin 6).
Model No.: |
HC SR04 |
---|---|
Operating Voltage (V) |
5 |
Avg. Current Used (mA): |
2 |
Frequency (Hz) |
40000 |
Sensing Angle |
15° |
Max. Sensing Distance (cm) |
450 |
Weight (g): |
9 |
Sensor Cover Dia. (mm) |
16 |
PCB Size ( L x W ) mm |
45 x 20 |
Shipping Weight | 0.014 kg |
Shipping Dimensions | 5 × 4 × 3 cm |
// Define pins
const int trigPin = 7;
const int echoPin = 6;
// Define variables
long duration;
int distance;
void setup() {
// Initialize serial communication
Serial.begin(9600);
// Set trigPin as an OUTPUT
pinMode(trigPin, OUTPUT);
// Set echoPin as an INPUT
pinMode(echoPin, INPUT);
}
void loop() {
// Clear the trigPin by setting it LOW for a short duration
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
// Send a 10 microsecond pulse to trigger the sensor
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);
// Measure the duration of the echo pulse
duration = pulseIn(echoPin, HIGH);
// Calculate the distance (in cm) based on the speed of sound
distance = duration * 0.034 / 2;
// Print the distance to the Serial Monitor
Serial.print("Distance: ");
Serial.print(distance);
Serial.println(" cm");
// Delay before next measurement
delay(1000); // Adjust delay as needed
}
0 Reviews For this Product
![](https://electroboat.in/uploads/seller/electroboat_logo3.jpeg)