You are viewing an older revision! See the latest version
MMA7660 Accelerometer
The MMA7660 is a 6-bit triple-axis accelerometer with +/- 1.5g range. Its a low power sensor mainly to be used for orientation detection of mobile devices and uses an I2C interface.

Hello World!¶
Import program
00001 //Uses the measured z-acceleration to drive leds 2 and 3 of the mbed 00002 00003 #include "mbed.h" 00004 #include "MMA7660.h" 00005 00006 MMA7660 MMA(p28, p27); 00007 00008 DigitalOut connectionLed(LED1); 00009 PwmOut Zaxis_p(LED2); 00010 PwmOut Zaxis_n(LED3); 00011 00012 int main() { 00013 if (MMA.testConnection()) 00014 connectionLed = 1; 00015 00016 while(1) { 00017 Zaxis_p = MMA.z(); 00018 Zaxis_n = -MMA.z(); 00019 } 00020 00021 }
Library¶
Import library
Public Types |
|
| enum | Orientation |
|
The 6 different orientations and unknown. More... |
|
Public Member Functions |
|
| MMA7660 (PinName sda, PinName scl, bool active=true) | |
|
Creates a new
MMA7660
object.
|
|
| bool | testConnection (void) |
|
Tests if communication is possible with the
MMA7660
.
|
|
| void | setActive (bool state) |
|
Sets the active state of the
MMA7660
.
|
|
| void | readData (int *data) |
|
Reads acceleration data from the sensor.
|
|
| float | x (void) |
|
Get X-data.
|
|
| float | y (void) |
|
Get Y-data.
|
|
| float | z (void) |
|
Get Z-data.
|
|
| void | setSampleRate (int samplerate) |
|
Sets the active samplerate.
|
|
| Orientation | getSide (void) |
|
Returns if it is on its front, back, or unknown side.
|
|
| Orientation | getOrientation (void) |
|
Returns if it is on it left, right, down or up side.
|
|
| MMA7660 Signal Name | mbed pin |
|---|---|
| Vdd | Vout |
| Vss | Gnd |
| SCL | p27 |
| SDA | p28 |