3-Axis Digital Accelerometer is the key part in projects like orientation detection, gesture detection and Motion detection. This 3-Asix Digital Accelerometer(±1.5g) is based on Freescale's low power consumption module, MMA7660FC. It features up to 10,000g high shock surviability and configurable Samples per Second rate. For generous applications that don't require too large measurement range, this is a great choice because it's durable, energy saving and cost-efficient.

Dependencies:   Grove_3-Axis_Digital_Accelerometer_MMA7660FC_Library mbed

Fork of Seeed_Grove_3-Axis_Digital_Accelorometer_Example by Austin Blackstone

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 
00002 #include <mbed.h>
00003 #include "MMA7660.h"
00004 
00005 MMA7660 accelemeter;
00006 
00007 int main()
00008 {
00009     int8_t x, y, z;
00010     float ax,ay,az;
00011     accelemeter.init();  
00012     while(1){
00013         accelemeter.getXYZ(&x,&y,&z);
00014         printf("X=%d, Y=%d, Z=%d, ",x,y,z);
00015         
00016         accelemeter.getAcceleration(&ax,&ay,&az);
00017         printf("Accleration of X=%2.2fg, Y=%2.2fg, Z=%2.2fg\n\r",ax,ay,az);
00018         wait(.5);
00019     }
00020 }