User Guide HC-SR04 (ElecFreaks) - 5

ManufacturerElecFreaks
DescriptionUltrasonic transmitter emitted an ultrasonic wave in one direction, and started timing when it launched.
Pages / Page6 / 5 — 3 2. . HC. H S. C R. S 0. R 4. 0 li. l b. i r. b a. r r. a y. r fu. f n. …
File Format / SizePDF / 740 Kb
Document LanguageEnglish

3 2. . HC. H S. C R. S 0. R 4. 0 li. l b. i r. b a. r r. a y. r fu. f n. u c. n t. c i. t o. i n. o de. d s. e c. s r. r p. i t. p i. L n. o g. n ti. t m. i i. m n. i g. n (. g ). f o. l a. o t

3 2  HC H S C R S 0 R 4 0 li l b i r b a r r a y r fu f n u c n t c i t o i n o de d s e c s r r p i t p i L n o g n ti t m i i m n i g n ( g ) f o l a o t

Text Version of Document

3. 3 2 . HC H S C R S 0 R 4 0 li l b i r b a r r a y r fu f n u c n t c i t o i n o de d s e c s r c i r p i t p i t o i n o Lo L n o g n ti t m i i m n i g n ( g ) (
Function name: timing Parameters: None Return Value: the time of ultrasonic from the transmitter to the receiver
fl f o l a o t a Ca C l a c l D c i D s i t s a t n a c n e c ( e l ( o l n o g n mi m c i r c o r s o e s c e , c i , n i t n me m t e r t i r c i ) c
Function name:CalcDistance � microsec: the time of ultrasonic from the transmitter to the receiver � metric: Set the unit of the return value ( the value of 1 for cm, and the value of 0 for in ) Return Value: the measured distance
3. 3 3 . Ad A d d th t e h HC H - C S - R S 0 R 4 0 Li L b i r b a r r a y r
Step1:Download the Demo Code of HCSR04 Ultrasonic from address http://www.elecfreaks.com/store/download/product/Sensor/HC-SR04/HCSR04Ultrasonic_demo.zip and then unpack it to get the file of HCSR04 Ultrasonic. Step2: Add the file of HCSR04 Ultrasonic in the file of Arduino-1.0.X / libraries. Step3:If you can see the Example of HCSR04 Ultrasonic in Arduino IDE, the adding of HC-SR04 library has been successful.
3. 3 4 . Te T s e t s th t e h Mo M d o u d l u e l wi w t i h t th t e h Ex E a x m a p m l p e l s e of o Li L b i r b a r r a y r Fi F l i e l
1. Open Arduino IDE 1.0.X, and choose the corresponding board and serial port. 2. Click file/ examples/ HCSR04Ultrasonic until the code pop up. 3. Compiling sketch until Done uploading appears, which represents the uploading has been successful. 4. Open serial monitor and set the corresponding BaudRate. 5. If you see similar information in serial monitor as below, you succeeded. 5 Document Outline HC-SR04UserGuide Part1UltrasonicIntroduction 1.1UltrasonicDefinition Thehumanearcanhearsoundfrequencyaround20HZ 1.2Ultrasonicdistancemeasurementprinciple Ultrasonictransmitteremittedanultrasonicwave 1.3UltrasonicApplication Part2HC-SR04UltrasonicModuleIntroduction 2.1ProductFeatures 2.2ProductImage 2.3、Modulepindefinitions 2.4、Electricalparameters 2.5ModuleoperatingPrinciple Part3UseFreaduinoUNOtotestHC-SR04 3.1FreaduinounoandHC-SR04Connection 3.2HCSR04libraryfunctiondescription Longtiming() floatCalcDistance(longmicrosec,intmetric) 3.3AddtheHC-SR04Library 3.4TesttheModulewiththeExamplesofLibraryF
EMS supplier