upm  1.5.0
Sensor/Actuator repository for libmraa (v1.8.0)
Public Member Functions

API for the ADXL335 3-Axis Analog Accelerometer. More...

Detailed Description

UPM module for the ADXL335 3-axis analog accelerometer. This was tested on a Grove 3-axis Analog Accelerometer. It uses 3 analog pins, one for each axis: X, Y, and Z.

// Instantiate an ADXL335 accelerometer on analog pins A0, A1, and A2
upm::ADXL335 accel(0, 1, 2);
cout << "Please make sure the sensor is completely still. Sleeping for"
<< " 2 seconds." << endl;
cout << "Calibrating..." << endl;
while (shouldRun) {
int x, y, z;
float aX, aY, aZ;
accel.values(&x, &y, &z);
cout << "Raw Values: X: " << x << " Y: " << y << " Z: " << z << endl;
accel.acceleration(&aX, &aY, &aZ);
cout << "Acceleration: X: " << aX << "g" << endl;
cout << "Acceleration: Y: " << aY << "g" << endl;
cout << "Acceleration: Z: " << aZ << "g" << endl;
cout << endl;

Public Member Functions

 ADXL335 (int pinX, int pinY, int pinZ, float aref=ADXL335_DEFAULT_AREF)
 ~ADXL335 ()
void setZeroX (float zeroX)
void setZeroY (float zeroY)
void setZeroZ (float zeroZ)
void values (int *xVal, int *yVal, int *zVal)
void acceleration (float *xAccel, float *yAccel, float *zAccel)
void calibrate ()

Constructor & Destructor Documentation

ADXL335 ( int  pinX,
int  pinY,
int  pinZ,
float  aref = ADXL335_DEFAULT_AREF 

ADXL335 constructor

pinXAnalog pin to use for X-axis
pinYAnalog pin to use for Y-axis
pinZAnalog pin to use for Z-axis
arefAnalog reference voltage; default is 5.0v
~ADXL335 ( )

ADXL335 destructor

Member Function Documentation

void setZeroX ( float  zeroX)

Sets the "zero" value of the X-axis, determined through calibration

zeroX"Zero" value of the X-axis
void setZeroY ( float  zeroY)

Sets the "zero" value of the Y-axis, determined through calibration

zeroY"Zero" value of the Y-axis
void setZeroZ ( float  zeroZ)

Sets the "zero" value of the Z-axis, determined through calibration

zeroZ"Zero" value of the Z-axis

Here is the call graph for this function:

void values ( int *  xVal,
int *  yVal,
int *  zVal 

Gets the analog values for the 3 axes

xValPointer to the returned X-axis value
yValPointer to the returned Y-axis value
zValPointer to the returned Z-axis value

Here is the caller graph for this function:

void acceleration ( float *  xAccel,
float *  yAccel,
float *  zAccel 

Gets the acceleration along all 3 axes

xAccelPointer to returned X-axis value
yAccelPointer to returned Y-axis value
zAccelPointer to returned Z-axis value

Here is the caller graph for this function:

void calibrate ( )

While the sensor is still, measures the X-axis, Y-axis, and Z-axis values and uses those values as the zero values.

Here is the caller graph for this function:

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