Darrel Weng / MMA8451Q

Fork of MMA8451Q by Antonio Quevedo

Embed: (wiki syntax)

« Back to documentation index

MMA8451Q Class Reference

MMA8451Q Class Reference

MMA8451Q accelerometer example, 8-bit samples. More...

#include <MMA8451Q.h>

Public Member Functions

 MMA8451Q (PinName sda, PinName scl)
 MMA8451Q constructor.
 ~MMA8451Q ()
 MMA8451Q destructor.
void getAccAllAxis (int16_t *res)
 Get XYZ axis acceleration, 8-bits.

Detailed Description

MMA8451Q accelerometer example, 8-bit samples.

 #include "mbed.h"
 #include "MMA8451Q.h"
 
 int main(void) {
 
 MMA8451Q acc(PTE25, PTE24);
 PwmOut rled(LED_RED);
 PwmOut gled(LED_GREEN);
 PwmOut bled(LED_BLUE);
 uint8_t data[3];

     while (true) {
          acc.getAccAllAxis(data);       
         rled = 1.0 - abs(data[0]/128);
         gled = 1.0 - abs(data[0]/128);
         bled = 1.0 - abs(data[0]/128);
         wait(0.4);
     }
 }

Definition at line 50 of file MMA8451Q.h.


Constructor & Destructor Documentation

MMA8451Q ( PinName  sda,
PinName  scl 
)

MMA8451Q constructor.

Parameters:
sdaSDA pin
sdlSCL pin

Definition at line 35 of file MMA8451Q.cpp.

~MMA8451Q (  )

MMA8451Q destructor.

Definition at line 58 of file MMA8451Q.cpp.


Member Function Documentation

void getAccAllAxis ( int16_t *  res )

Get XYZ axis acceleration, 8-bits.

Parameters:
resarray where acceleration data will be stored

Definition at line 60 of file MMA8451Q.cpp.