Ultrasonic Range Finder HC-SR04
The HC-SR04 is range-finding sensor utilizing reflection of ultrasonic to measure the distance to an object.
Specifications:
- Power supply voltage: 5V
- Standby current: less than 2mA
- Signal output: 0-5V
- Measurable Angle: 15degrees
- Measurable distance: 2cm-450cm
- Resolution: 0.3cm
- Terminal interval: 2.54mm
How to use:
1.Set the trigger input for at least 10us High level signal.
2.The sensor module sends eight 40kHz pulse signal for 8 times and detect it.
3.When the signal is detected, the output terminal becomes High level.
4.When the signal is back, through High, time of High level output duration is the time from sending ultrasonic to returning.
5.The distance = (High level time × velocity of sound (340M/S) / 2
View from an Oblique Direction:
Sample Sketch for Arduino:
If the Trig connection is connected to the DB of Arduino, and the Echo connection is connected to the D9.
int Trig = 8;
int Echo = 9;
int Duration;
float Distance;
void setup() {
Serial.begin(9600);
pinMode(Trig,OUTPUT);
pinMode(Echo,INPUT);
}
void loop() {
digitalWrite(Trig,LOW);
delayMicroseconds(1);
digitalWrite(Trig,HIGH);
delayMicroseconds(1);
digitalWrite(Trig,LOW);
Duration = pulseIn(Echo,HIGH);
if (Duration>0) {
Distance = Duration/2;
Distance = Distance*340*100/1000000; // ultrasonic speed is 340m/s = 34000cm/s = 0.034cm/us
Serial.print(Duration);
Serial.print(" us ");
Serial.print(Distance);
Serial.println(" cm");
}
delay(500);
}
|
|
Name | Ultrasonic Range Finder HC-SR04 |
---|---|
Code | SSCI-016063 |
SKU# | 1606 |