This program reads the MMA7455 Accelerometer unit on the LPC4088 Base Board and outputs to UART

Dependencies:   EALib mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "MMA7455.h"
00003 
00004 MMA7455 sens(P0_27,P0_28);
00005 Serial pc(USBTX, USBRX);
00006 
00007 int main()
00008 {
00009     pc.baud(19200);
00010     int x,y,z;//val[3] = [0,0,0];
00011     pc.printf("[X, Y, Z] = \n\r");
00012     
00013     while(!sens.setMode(MMA7455::ModeMeasurement)); //Setting mode : Measurement
00014     while(!sens.calibrate());                       //Calibrating axis
00015     
00016     while(1)
00017     {        
00018         sens.read(x, y, z);
00019         pc.printf("[%d.1, %d.1, %d.1]\r", x, y, z);
00020         wait(2);
00021     }
00022 }