upm  1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
Public Member Functions

API for the LV-MaxSonar-EZ Family of Ultrasonic Rangers. More...

Detailed Description

Sensors of this family return an analog voltage corresponding to the distance of an object from the sensor in inches. They have a resolution of about 9.7 millivolts per inch with an analog reference voltage of 5.0 V. The differences between various versions (EZ1, EZ2, etc.) are related to the narrowness of the beam angle.

This class supports these sensors with an analog input only.

This driver was developed using an LV-MaxSonar-EZ3 ultrasonic ranger.

maxsonarez.jpg


LV-MaxSonar-EZ Ultrasonic Ranger image provided by SparkFun* under CC BY 2.0.

// Instantiate a MaxSonarEZ on analog pin A1, with an analog
// reference voltage of MAXSONAREZ_AREF
upm::MAXSONAREZ sonar(1, MAXSONAREZ_AREF);
// Every second, sample the sonar and output the distance to an
// object in inches.
// With the EZ3 version, the minimum and maximum ranges seemed to be
// between 6 and 33 inches
while (shouldRun) {
cout << "AREF: " << MAXSONAREZ_AREF << ", distance in inches: " << sonar.inches() << endl;
upm_delay(1);
}

Public Member Functions

 MAXSONAREZ (int pin, float aref=5.0)
 
 ~MAXSONAREZ ()
 
int inches ()
 

Constructor & Destructor Documentation

MAXSONAREZ ( int  pin,
float  aref = 5.0 
)

MAXSONAREZ constructor

Parameters
pinAnalog pin to use
arefAnalog reference voltage; default is 5.0 V
~MAXSONAREZ ( )

MAXSONAREZ destructor

Member Function Documentation

int inches ( )

Gets the distance to the object in inches

Returns
Distance to the object in inches

The documentation for this class was generated from the following files: