Ultrasonic Ranging Detector Module HC-SR04
If you are sourcing a ultrasonic ranging module , the HC-SR04 is good choose . Its stable performance and high ranging accuracy make it a popular module in electronic market .
Compared to the Shap IR ranging module , HC-SR04 is more inexpensive than it .
But it has the same ranging accuracy and longer ranging distance.
Specifications
- Power supply: 5V DC
- Quiescent current: <2mA
- Effectual angle: <15°
- Ranging distance: 2cm – 500 cm
- Resolution: 1 cm
- Ultrasonic Frequency:40k Hz
Datasheet
- DS_IM120628012_HC_SR04.pdf2012-07-07 02:39:40526KB
Library
- Lib_IM120628012_HC_SR04.zip2012-07-07 02:39:262.1KB
Sample Code:
/*
HC-SR04 Ping distance sensor
VCC to arduino 5v GND to arduino GND
Trig to Arduino pin 12
Echo to Arduino pin 13
*/
#define trigPin 13
#define echoPin 12
void setup() {
Serial.begin (9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
}
void loop() {
long duration, distance;
digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10); // Added this line
digitalWrite(trigPin, LOW);
duration = pulseIn(echoPin, HIGH);
delay(500);
}