![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Measure Distance
Diff: hcsr04.cpp
- Revision:
- 5:e70a24a88131
- Parent:
- 4:33938a97d904
- Child:
- 6:4be4fcd0c171
--- a/hcsr04.cpp Sat Mar 30 18:46:01 2013 +0000 +++ b/hcsr04.cpp Sat Mar 30 18:50:32 2013 +0000 @@ -71,3 +71,28 @@ { return pulsedur; } + + + +/******************************************************* + Here is a sample code usage +********************************************************* +#include "hcsr04.h" +DistMeasure usensor(p25,p6); +int main() +{ + unsigned char count=0; + while(1) { + usensor.start(); + wait_ms(500); + dist=usensor.get_dist_cm(); + lcd.cls(); + lcd.locate(0,0); + lcd.printf("cm:%ld",dist ); + + count++; + lcd.locate(0,1); + lcd.printf("Distance =%d",count); + + } +*/ \ No newline at end of file