HC-SR04 Ultrasonic Sensor Distance Measuring Module

From air
Revision as of 06:35, 10 August 2012 by Donsez (talk | contribs) (→‎Arduino)
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

Arduino

File:Arduino+HCSR04.jpg
HCSR-04 with Arduino Nano
#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);
}