Class to handle triggering and reading the distance measured by a range finder.

Dependencies:   Pulse

Dependents:   SeeedUltrasoundRangeFinder Ultrasonic_sensor_circle_ui riversensor Labo_TRSE_Drone ... more

Embed: (wiki syntax)

« Back to documentation index

RangeFinder Class Reference

RangeFinder Class Reference

Range Finder class. More...

#include <RangeFinder.h>

Public Member Functions

 RangeFinder (PinName pin, int pulsetime, float scale, int timeout)
 Create a RangeFinder object.
float read_m ()
 Return the distance to the nearest object, or -1.0 if reading the pulse timed out.

Detailed Description

Range Finder class.

Definition at line 30 of file RangeFinder.h.


Constructor & Destructor Documentation

RangeFinder ( PinName  pin,
int  pulsetime,
float  scale,
int  timeout 
)

Create a RangeFinder object.

Parameters:
pinDigital I/O pin the range finder is connected to.
pulsetimeTime of pulse to send to the rangefinder to trigger a measurement, in microseconds.
scaleScaling of the range finder's output pulse from microseconds to metres.
timeoutTime to wait for a pulse from the range finder before giving up.

Definition at line 25 of file RangeFinder.cpp.


Member Function Documentation

float read_m (  )

Return the distance to the nearest object, or -1.0 if reading the pulse timed out.

Definition at line 32 of file RangeFinder.cpp.