DESCRIPTION
Meet the HY-SRF05 – a longer range, more precise ultrasonic sensor. These sensors use a pulse of ultrasonic sound and listen for a response. Since the speed of sound is relatively stable, we can measure the time between the pulse and the echo to determine distance.
FEATURES
- Operating voltage: 5VDC
- Operating frequency: 40KHz
- 15° Field Of View
- Operating current: 2mA
- Range: 2 – 500cm
- Output: TTL level signal proportional to range
CONNECTION
REFERENCE CODING
const unsigned int TRIG_PIN=13; const unsigned int ECHO_PIN=12; const unsigned int BAUD_RATE=9600; void setup() { pinMode(TRIG_PIN, OUTPUT); pinMode(ECHO_PIN, INPUT); Serial.begin(BAUD_RATE); } void loop() { digitalWrite(TRIG_PIN, LOW); delayMicroseconds(2); digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalWrite(TRIG_PIN, LOW); const unsigned long duration= pulseIn(ECHO_PIN, HIGH); int distance= duration/29/2; if(duration==0){ Serial.println("Warning: no pulse from sensor"); } else{ Serial.print("distance to nearest object:"); Serial.println(distance); Serial.println(" cm"); } delay(100); }
Reviews
There are no reviews yet.