Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
HCSR04 Class Reference
#include <hcsr04.h>
Public Member Functions | |
HCSR04 (PinName TrigPin, PinName EchoPin) | |
Create a HCSR04 object connected to the specified pin. | |
float | get_dist_cm (void) |
Return the distance from obstacle in cm. | |
float | get_pulse_us (void) |
Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver. | |
void | start (void) |
Generates the trigger pulse of 10us on the trigger PIN. |
Detailed Description
HCSR04 Class(es)
Definition at line 32 of file hcsr04.h.
Constructor & Destructor Documentation
HCSR04 | ( | PinName | TrigPin, |
PinName | EchoPin | ||
) |
Create a HCSR04 object connected to the specified pin.
- Parameters:
-
pin i/o pin to connect to
Definition at line 5 of file hcsr04.cpp.
Member Function Documentation
float get_dist_cm | ( | void | ) |
Return the distance from obstacle in cm.
- Parameters:
-
distance in cms and returns -1, in case of failure
Definition at line 47 of file hcsr04.cpp.
float get_pulse_us | ( | void | ) |
Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver.
- Parameters:
-
pulse duration in microseconds.
Definition at line 51 of file hcsr04.cpp.
void start | ( | void | ) |
Generates the trigger pulse of 10us on the trigger PIN.
Definition at line 23 of file hcsr04.cpp.
Generated on Fri Dec 22 2023 09:30:32 by
