Ultrasound Ranging Sensor module

Dependents:   Obstacle_avoidance servourfmatlab hcsr04 DistanceOnSevenSegLed ... more

Embed: (wiki syntax)

« Back to documentation index

HCSR04 Class Reference

HCSR04 Class Reference

HCSR04 Class(es) More...

#include <hcsr04.h>

Public Member Functions

 HCSR04 (PinName TrigPin, PinName EchoPin)
 Create a HCSR04 object connected to the specified pin.
unsigned int get_dist_cm (void)
 Return the distance from obstacle in cm.
unsigned int 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:
pini/o pin to connect to

Definition at line 24 of file hcsr04.cpp.


Member Function Documentation

unsigned int get_dist_cm ( void   )

Return the distance from obstacle in cm.

Parameters:
distancein cms and returns -1, in case of failure

Definition at line 66 of file hcsr04.cpp.

unsigned int get_pulse_us ( void   )

Return the pulse duration equal to sonic waves travelling to obstacle and back to receiver.

Parameters:
pulseduration in microseconds.

Definition at line 70 of file hcsr04.cpp.

void start ( void   )

Generates the trigger pulse of 10us on the trigger PIN.

Definition at line 42 of file hcsr04.cpp.