Danny Eldering / Mbed 2 deprecated KXTJ3

Dependencies:   mbed

Dependents:   SP_BEUNBOX_code

Fork of KX022 by Rohm

Embed: (wiki syntax)

« Back to documentation index

KXTJ3 Class Reference

KXTJ3 Class Reference

KXTJ3 accelerometer example. More...

#include <KXTJ3.h>

Public Member Functions

 KXTJ3 (I2C *i2c_obj, int addr=KXTJ3_DEFAULT_SLAVE_ADDRESS)
 KXTJ3 constructor.
 ~KXTJ3 ()
 KXTJ3 destructor.
void initialize (void)
 Initializa KXTJ3 sensor.
float getAccX ()
 Get X axis acceleration.
float getAccY ()
 Get Y axis acceleration.
float getAccZ ()
 Get Z axis acceleration.
void getAccAllAxis (float *res)
 Get XYZ axis acceleration.

Detailed Description

KXTJ3 accelerometer example.

 #include "mbed.h"
 #include "KXTJ3.h"

 int main(void) {

 KXTJ3 acc(I2C_SDA, I2C_SCL);
 PwmOut rled(LED_RED);
 PwmOut gled(LED_GREEN);
 PwmOut bled(LED_BLUE);

     while (true) {
         rled = 1.0 - abs(acc.getAccX());
         gled = 1.0 - abs(acc.getAccY());
         bled = 1.0 - abs(acc.getAccZ());
         wait(0.1);
     }
 }

Definition at line 81 of file KXTJ3.h.


Constructor & Destructor Documentation

KXTJ3 ( I2C *  i2c_obj,
int  addr = KXTJ3_DEFAULT_SLAVE_ADDRESS 
)

KXTJ3 constructor.

Parameters:
sdaSDA pin
sdlSCL pin
addrslave address of the I2C peripheral (default: 0x3C) Create a KXTJ3 instance which is connected to specified I2C pins with specified address
i2c_objI2C object (instance)
addrslave address of the I2C-bus peripheral (default: 0x3C)

Definition at line 38 of file KXTJ3.cpp.

~KXTJ3 (  )

KXTJ3 destructor.

Definition at line 43 of file KXTJ3.cpp.


Member Function Documentation

void getAccAllAxis ( float *  res )

Get XYZ axis acceleration.

Parameters:
resarray where acceleration data will be stored

Definition at line 91 of file KXTJ3.cpp.

float getAccX (  )

Get X axis acceleration.

Returns:
X axis acceleration

Definition at line 76 of file KXTJ3.cpp.

float getAccY (  )

Get Y axis acceleration.

Returns:
Y axis acceleration

Definition at line 81 of file KXTJ3.cpp.

float getAccZ (  )

Get Z axis acceleration.

Returns:
Z axis acceleration

Definition at line 86 of file KXTJ3.cpp.

void initialize ( void   )

Initializa KXTJ3 sensor.

Configure sensor setting

Definition at line 47 of file KXTJ3.cpp.