Difference between revisions of "Ultrasonic Sensor Breakout SRF04"
Qian.zhang (talk | contribs) (Created page with "== Introduction == Ultrasonic sensor is non-contact distance measurement module, which is also compatible with electronic brick. It’s designed for easy modular project usag...") |
Qian.zhang (talk | contribs) (→Specification) |
||
Line 45: | Line 45: | ||
| 43x20x15 mm | | 43x20x15 mm | ||
|} | |} | ||
+ | |||
+ | == Usage == | ||
+ | |||
+ | ===Ultra Sonic Timing Diagram=== | ||
+ | |||
+ | [[File:Ultra_Timing.jpg]] | ||
+ | |||
+ | ===Programming=== | ||
+ | |||
+ | <syntaxhighlight lang="c"> | ||
+ | const int pingPin = 7; | ||
+ | const int start_signal = 8; | ||
+ | void setup() | ||
+ | { | ||
+ | Serial.begin(9600); | ||
+ | } | ||
+ | void loop() | ||
+ | { | ||
+ | long duration, inches, cm; | ||
+ | pinMode(pingPin, OUTPUT); | ||
+ | pinMode(start_signal, OUTPUT); | ||
+ | digitalWrite(start_signal, HIGH); | ||
+ | delayMicroseconds(20); | ||
+ | digitalWrite(start_signal, LOW); | ||
+ | digitalWrite(pingPin, LOW); | ||
+ | delayMicroseconds(2); | ||
+ | digitalWrite(pingPin, HIGH); | ||
+ | delayMicroseconds(5); | ||
+ | digitalWrite(pingPin, LOW); | ||
+ | pinMode(pingPin, INPUT); | ||
+ | duration = pulseIn(pingPin, HIGH); | ||
+ | inches = microsecondsToInches(duration); | ||
+ | cm = microsecondsToCentimeters(duration); | ||
+ | Serial.print(inches); | ||
+ | Serial.print("in, "); | ||
+ | Serial.print(cm); | ||
+ | Serial.print("cm"); | ||
+ | Serial.println(); | ||
+ | delay(80); | ||
+ | } | ||
+ | long microsecondsToInches(long microseconds) | ||
+ | { | ||
+ | return microseconds / 74 / 2; | ||
+ | } | ||
+ | long microsecondsToCentimeters(long microseconds) | ||
+ | { | ||
+ | return microseconds / 29 / 2; | ||
+ | } | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | == How to buy == | ||
+ | |||
+ | Here to buy Ultrasonic Sensor Breakout SRF04 on [http://store.linksprite.com/ultrasonic-sensor-breakout-srf04/ store] |
Latest revision as of 01:45, 17 March 2015
Contents
Introduction
Ultrasonic sensor is non-contact distance measurement module, which is also compatible with electronic brick. It’s designed for easy modular project usage with industrial performance.
Features
- Detecting range: 3cm-4m
- Best in 30 degree angle
- Electronic brick compatible interface
- 5VDC power supply
- Breadboard friendly
- Dual transducer
- Arduino library ready
Specification
Supply voltage | 5V |
Global Current Consumption | 15 mA |
Ultrasonic Frequency | 40k Hz |
Maximal Range | 400 cm |
Minimal Range | 3 cm |
Resolution | 1 cm |
Trigger Pulse Width | 10 μs |
Outline Dimension | 43x20x15 mm |
Usage
Ultra Sonic Timing Diagram
Programming
<syntaxhighlight lang="c"> const int pingPin = 7; const int start_signal = 8; void setup() {
Serial.begin(9600);
} void loop() {
long duration, inches, cm; pinMode(pingPin, OUTPUT); pinMode(start_signal, OUTPUT); digitalWrite(start_signal, HIGH); delayMicroseconds(20); digitalWrite(start_signal, LOW); digitalWrite(pingPin, LOW); delayMicroseconds(2); digitalWrite(pingPin, HIGH); delayMicroseconds(5); digitalWrite(pingPin, LOW); pinMode(pingPin, INPUT); duration = pulseIn(pingPin, HIGH); inches = microsecondsToInches(duration); cm = microsecondsToCentimeters(duration); Serial.print(inches); Serial.print("in, "); Serial.print(cm); Serial.print("cm"); Serial.println(); delay(80);
} long microsecondsToInches(long microseconds) {
return microseconds / 74 / 2;
} long microsecondsToCentimeters(long microseconds) {
return microseconds / 29 / 2;
} </syntaxhighlight>
How to buy
Here to buy Ultrasonic Sensor Breakout SRF04 on store