Arduino Library For Ultrasonic Ranging Module HC-SR04 - ITead Studio
Arduino Library For Ultrasonic Ranging Module HC-SR04 - ITead Studio
Arduino Library For Ultrasonic Ranging Module HC-SR04 - ITead Studio
ITead Studio
Make innovation easier Feed Rss Blog Archive iStore iMall Distributors iForum About us
We have already sold many HC-SR04 modules , though its easy use and we has published a demo ,still some user mail us for a specialized code of his own use even just change the different Arduino pins for module. So we decide to release a Arduino Library for those beginning user . You just need to add the library into your Arduino , and call for a function , you can get the distance. Download the Library , unzip the release package to arduino-0018/libraries/ folder. Open the Arduino IDE , you can include the library by Sketch-Import library-Ultrasonic . And you can find the example sketch in File-Examples-Ultrasonic-UltrasonicDemo . Here we give out a brief introduction of this ultrasonic ranging library. It includes 3 function for user : 1. Ultrasonic(int TP, int EP) This is a initial function for ultrasonic ranging module, choose the pins for module Trig and Echo pin. example: Ultrasonic(13,12); then you define the digital pin 13 of Arduino for the Trig pin of HC-SR04. And the pin 12 for Echo pin. 2. long Timing() Trigger the ultrasonic ranging module work and return the duration that Echo pin keep high level. example: long time; Ultrasonic hcsr; time = hcsr.Timing(); Then you start the HC-SR04 for ranging and you get the time the Echo pin keep high, you can change the time corresponds to the distance : Distance = ((Duration of high level)*(Sonic :340m/s))/2 3. long Ranging(int sys) (sys : CM / INC) If you dont want to change the time into distance yourself , this function will help you get the distance immediate. And the function has a parameter sys, you can use CM or ICN , than you get the distance show as centimeter or inch. This function will call the Timing() and you dont need to use the Timing() before it. example: long distance; Ultrasonic hcsr; distance = hcsr.Ranging(CM); OK, now you get the distance in centimeter . Its very easy , right ? Download the library for HC-SR04 ultrasonic ranging module here : Ultrasonic ranging library (1.4 KiB, 11,233 hits) Adicionar ao Reddit
iteadstudio.com/application-note/arduino-library-for-ultrasonic-ranging-module-hc-sr04/ 1/4
13/10/12
You may also be interested in these posts: 1. 2. 3. 4. 5. Cheap-cheap Ultrasonic Ranging Module:HC-SR04 Arduino Ultrasonic Ranging With HC-SR04 Serial Ultrasonic Module JSME007TX ITDB02 Arduino Library V1.3 ITDB02 TFT LCD Library For Arduino
Tags: Arduino, Library, ranging Back Top 2.4G Wireless Module : nRF24L01 Module Breakout board for SMD ICs
13/10/12
raz at May 27, 2012 11:09 AM Reply 1. Sensore di distanza ad ultrasuoni con Arduino Giuseppe Fatiguso's Blog (,June 7, 2011) [...] Quello che rende semplice questo sketch di esempio, che esiste una libreria software per questo sensore per arduino, scaricabile a questa pagina. [...] 2. La domotique chez Benchi - Arduino et la mesure de distance par ultrason hc-sr04 (,August 14, 2011) [...] http://iteadstudio.com/application-note/arduino-library-for-ultrasonic-ranging-module-hc-sr04/ Partager: [...] 3. Eletrnica digital com Arduino: sensor ultrasnico + servo motor = olhos | Djames Suhanko Linux e Programao (,August 19, 2011) [...] bastante popular em Arduino tanto que possui at uma biblioteca, que pode ser baixada nesse link. Baixe o arquivo e extraia-o em arduino-0022/libraries/. Ser criado um diretrio chamado [...] 4. Domotique - Connaitre le niveau d'une cuve de rcupration d'eau | Blog de C-quad (,August 23, 2011) [...] cout est plutt faible 10$ et un librairie pour Arduino est [...] 5. HC-SR04 Um sensor de Ultra Som barato Kemper.com.br Robtica com Carter Social (,August 31, 2011) [...] O site contendo a documentao original em ingls pode ser encontrado neste link. [...] 6. Arduino Arts Archive Tutorials with Arduino: Range Sensor with LCD and 7 segment led #display #arduino (,September 10, 2011) [...] You can download the library here. [...] 7. Tutorials with Arduino: Range Sensor with LCD and 7 segment led #display #arduino / Cooking Hacks Blog (,September 11, 2011) [...] You can download the library here. [...] 8. My First Arduino Robot Bobs Mods (,December 5, 2011) [...] This was very helpful for setting up my ultrasonic sensors, also this. [...] 9. Finding distance/range using arduino Mambohead (,December 27, 2011) [...] went and got the library here. #include Ultrasonic.h Ultrasonic ultrasonic( 12, 13 [...] 10. Counting Human Activity with an Arduino, Part 1 DBP Harrison (,July 10, 2012) [...] 3 and works a little differently, with a pin for triggering and another for receiving an echo. An Arduino library is available so there is no reason to shy away from using them, especially when they can be [...]
Leave a Reply
Name(required) Mail (will not be published)(required)
iteadstudio.com/application-note/arduino-library-for-ultrasonic-ranging-module-hc-sr04/ 3/4
13/10/12
Website
Submit Comments
iteadstudio.com/application-note/arduino-library-for-ultrasonic-ranging-module-hc-sr04/
4/4