HCSR04 - Mehmet Akif Arvas
Revision 1:f746a7bb4e54, committed 2021-07-06
- Comitter:
- marvas
- Date:
- Tue Jul 06 10:17:17 2021 +0000
- Parent:
- 0:86b2086be101
- Commit message:
- HCSR04 - Mehmet Akif Arvas
Changed in this revision
hcsr04.cpp | Show annotated file Show diff for this revision Revisions of this file |
hcsr04.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/hcsr04.cpp Mon Apr 14 08:23:09 2014 +0000 +++ b/hcsr04.cpp Tue Jul 06 10:17:17 2021 +0000 @@ -4,7 +4,7 @@ *HCSR04.cpp */ HCSR04::HCSR04(PinName t, PinName e) : trig(t), echo(e) {} - long HCSR04::echo_duration() { + int HCSR04::echo_sure() { timer.reset(); //reset timer trig=0; // trigger low @@ -21,9 +21,9 @@ } //return distance in cm -long HCSR04::distance(){ - duration = echo_duration(); - distance_cm = (duration/2)/29.1 ; - return distance_cm; +int HCSR04::uzaklik(){ + sure = echo_sure(); + mesafe_cm = (sure/2)/29.1 ; + return mesafe_cm; } \ No newline at end of file
--- a/hcsr04.h Mon Apr 14 08:23:09 2014 +0000 +++ b/hcsr04.h Tue Jul 06 10:17:17 2021 +0000 @@ -37,14 +37,14 @@ class HCSR04 { public: HCSR04(PinName t, PinName e); - long echo_duration(); - long distance(); + int echo_sure(); + int uzaklik(); private: DigitalOut trig; DigitalIn echo; Timer timer; - long duration,distance_cm; + int sure,mesafe_cm; }; #endif \ No newline at end of file