Jacob Johnson / Mbed OS mbed-Accelerometer-example-NCS36510

Dependencies:   Grove_3-Axis_Digital_Accelerometer_MMA7660FC_Library SeeedGrayOLED mbed-os

Fork of Seeed_Grove_3-Axis_Digital_Accelorometer_Example by Seeed

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 #include "SeeedGrayOLED.h"
00005 
00006 MMA7660 accelemeter;
00007 
00008 int main()
00009 {
00010     int8_t x, y, z;
00011     float ax,ay,az;
00012     accelemeter.init();  
00013         
00014     while(1){
00015         accelemeter.getXYZ(&x,&y,&z);
00016         printf("X=%d, Y=%d, Z=%d, ",x,y,z);
00017         
00018       
00019             
00020         accelemeter.getAcceleration(&ax,&ay,&az);
00021         printf("Accleration of X=%2.2fg, Y=%2.2fg, Z=%2.2fg\n\r",ax,ay,az);
00022         wait(.5);
00023     }
00024 }