This library is for the HC-SR04 ultrasonic ranging module . The module is very easy use , now with the library , user just need a function then he can get the distance .
HCSR04 ultrasonic sensor. Allows an Arduino board to use HCSR04 module. This library allows an Arduino board to use multiple HCSR04 sensors for get current distance in cm. To do that, you should have Proteus already installed on your computer system, then add Arduino and ultrasonic sensor libraries to the Proteus library folder, once you have done that, you open Proteus and draw the circuit diagram as shown below. Figure 1: HC-SR04 simulation on Proteus.
Library includes 3 functions for user :
Ultrasonic(int TP, int EP)
This is a initial function for ultrasonic ranging module, choose the pins for module Trig and Echo pin. You need using this function before Setup() to define the pin map.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.
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
long Ranging(int sys)
If you don't 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 don't need to use the Timing() before it.example: long distance; Ultrasonic hcsr; distance = hcsr.Ranging(CM);
;) Hope it help.
Simulation of HC SR04 Ultrasonic Sensor with Arduino in Proteus to Measure Distance
Simulation of HC SR04 Ultrasonic Sensor to measure distance and is calculated in cm. The numerical value gets displayed on the LCD screen as well as on the Virtual Terminal, the data in the virtual terminal can be used to light up alarming LED Red, or Sound for blind.