Allows the M3Pi to be used as a Sumo robot, using the sharp 100 distance sensors on the front. Run away strategy

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

SharpDigiDist100 Class Reference

SharpDigiDist100 Class Reference

A class which interfaces with a Sharp Digital Distance sensor (GP2Y0D810) More...

#include <SharpDigiDist100.h>

Public Types

enum  Distance
 

The enum which makes up the output.

More...

Public Member Functions

 SharpDigiDist100 (PinName pin)
 Create a sensor input.
int getDistance ()
 Returns the distace as an enum.
void attachOnChange (void(*ptr)(void))
 Attaches a function which is called on distance change.

Detailed Description

A class which interfaces with a Sharp Digital Distance sensor (GP2Y0D810)

Example:

Definition at line 15 of file SharpDigiDist100.h.


Member Enumeration Documentation

enum Distance

The enum which makes up the output.

Definition at line 30 of file SharpDigiDist100.h.


Constructor & Destructor Documentation

SharpDigiDist100 ( PinName  pin )

Create a sensor input.

Parameters:
pinThe pin the output of the sensor is connected to

Definition at line 3 of file SharpDigiDist100.cpp.


Member Function Documentation

void attachOnChange ( void(*)(void)  ptr )

Attaches a function which is called on distance change.

Parameters:
Apointer to a function with params/returns: void func(void)

Definition at line 52 of file SharpDigiDist100.cpp.

int getDistance (  )

Returns the distace as an enum.

Returns:
The distance code: 1 is near, 2 is middle distance and 3 is far

Definition at line 47 of file SharpDigiDist100.cpp.