Library for the SRF05 Ultrasonic Rangefinder

Dependents:   SRF05_HelloWorld Final_Sonar MyFinalDerbot Ultra_Infra_TEST1 ... more

Embed: (wiki syntax)

« Back to documentation index

SRF05 Class Reference

SRF05 Class Reference

Library for the SRF05 Ultrasonic range finder. More...

#include <SRF05.h>

Public Member Functions

 SRF05 (PinName trigger, PinName echo)
 Create a SRF05 object, connected to the specified pins.
float read ()
 A non-blocking function that will return the last measurement.
 operator float ()
 A short hand way of using the read function.

Detailed Description

Library for the SRF05 Ultrasonic range finder.

Example:

 // Print measured distance

 #include "mbed.h"
 #include "SRF05.h"

 SRF05 srf(p9,p10);

 int main() {
     while(1) {
         printf("Measured : %.1f\n", srf.read());
         wait(0.2);
     }
 }

Definition at line 47 of file SRF05.h.


Constructor & Destructor Documentation

SRF05 ( PinName  trigger,
PinName  echo 
)

Create a SRF05 object, connected to the specified pins.

Parameters:
triggerDigitalOut to the SRF05 trigger
echoInterruptIn to measure the return pulse

Definition at line 26 of file SRF05.cpp.


Member Function Documentation

operator float (  )

A short hand way of using the read function.

Definition at line 59 of file SRF05.cpp.

float read ( void   )

A non-blocking function that will return the last measurement.

Returns:
floating point representation of distance in cm

Definition at line 54 of file SRF05.cpp.