WebbotLib AVR library
WebbotLib It just does it
  C++ documentation  C documentation

AnalogDevices/ADXL345.h

The ADXL345 is a 3 axis accelerometer from Analog Devices capable of measuring ±16g.
Data sheet: http://www.sparkfun.com/datasheets/Sensors/Accelerometer/ADXL345.pdf
This library supports the device using I2C so pin 7 (CS) should be connected to pin 1 (Vdd) and pin 12 (SDO) can be used to select the I2C address. If pin 12 is connected to ground then the I2C address is 0xA6 and if pin 12 is connected to Vdd then the address is 0x3A.
The device can be created, specifying the I2C address, as follows:-
#include "AnalogDevices/ADXL345.h"
ADXL345 accel = MAKE_ADXL345(0xA6);
Having caused the sensor to be read using:-
accelerometerRead(accel);
Each axis can then be read independently:-
ACCEL_TYPE x = accel.accelerometer.x_axis_mG;
ACCEL_TYPE y = accel.accelerometer.y_axis_mG;
ACCEL_TYPE z = accel.accelerometer.z_axis_mG;
The values returned are in 'mG' ie 1000ths of the gravitational constant.
You can change the frequency at which the device recalculates new values. The default is 100 times per second. Higher frequencies generally consume more current.

 

Function

 


ADXL345_25Hz(const ADXL345* accel)

Configure the ADXL345 to refresh the values 25 times per second.

ADXL345_50Hz(const ADXL345* accel)

Configure the ADXL345 to refresh the values 50 times per second.

ADXL345_100Hz(const ADXL345* accel)

Configure the ADXL345 to refresh the values 100 times per second.

ADXL345_200Hz(const ADXL345* accel)

Configure the ADXL345 to refresh the values 200 times per second.

ADXL345_400Hz(const ADXL345* accel)

Configure the ADXL345 to refresh the values 400 times per second.

ADXL345_800Hz(const ADXL345* accel)

Configure the ADXL345 to refresh the values 800 times per second.

ADXL345_1600Hz(const ADXL345* accel)

Configure the ADXL345 to refresh the values 1,600 times per second.

ADXL345_3200Hz(const ADXL345* accel)

Configure the ADXL345 to refresh the values 3,200 times per second.

Valid XHTML 1.0 Transitional