HC-SR04 Ultrasonic Sensor Distance Measuring Module
Jump to navigation
Jump to search
HC-SR04 Ultrasonic Sensor Distance Measuring Module
- Model: HC-SR04 - Color: Blue + Silver - Working voltage : 5V(DC) - Static current: Less than 2mA. - Output signal: Electric frequency signal, high level 5V, low level 0V. - Sensor angle: Not more than 15 degrees. - Detection distance: 2cm~450cm. - High precision: Up to 3mm - Mode of connection: VCC / trig(T) / echo(R) / GND - Module Working Principle: - Adopt IO trigger through supplying at least 10us sequence of high level signal - The module automatically send eight 40khz square wave and automatically detect whether receive the returning pulse signal - If there is signals returning, through outputting high level and the time of high level continuing is the time of that from the ultrasonic transmitting to receiving
A lire
- http://www.arduino.cc/cgi-bin/yabb2/YaBB.pl?num=1272177425
- http://iteadstudio.com/application-note/arduino-library-for-ultrasonic-ranging-module-hc-sr04/
Arduino
// load the library for HC-SR04 http://iteadstudio.com/application-note/arduino-library-for-ultrasonic-ranging-module-hc-sr04/ // Remark: change the “WProgram.h” reference to “Arduino.h” in files "Ultrasonic.h" and "Ultrasonic.cpp" and everything will be fine #include "Ultrasonic.h" // Sensor VCC pin connected to Arduino pin 5V // Sensor GND pin connected to Arduino pin GND // Sensor TRIG pin connected to Arduino pin 12 // sensor ECHO pin connected to Arduino pin 13 Ultrasonic ultrasonic(12,13); void setup() { Serial.begin(9600); } void loop() { Serial.print(ultrasonic.Ranging(CM)); Serial.println(" cm"); delay(100); Serial.print(ultrasonic.Timing()); // Distance = ((Duration of high level)*(Sonic :340m/s))/2 Serial.println(" ms"); delay(100); }