FRDM Accelerometer Test

Dependencies:   FRDM_MMA8451Q mbed

Committer:
schematic
Date:
Wed Nov 13 11:13:43 2013 +0000
Revision:
0:dc9bb280dcd5
AccelTest

Who changed what in which revision?

UserRevisionLine numberNew contents of line
schematic 0:dc9bb280dcd5 1 #include "mbed.h"
schematic 0:dc9bb280dcd5 2
schematic 0:dc9bb280dcd5 3 #include "MMA8451Q.h"
schematic 0:dc9bb280dcd5 4 #define MMA8451_I2C_ADDRESS (0x1d<<1)
schematic 0:dc9bb280dcd5 5
schematic 0:dc9bb280dcd5 6 // --- Set Accelerometer
schematic 0:dc9bb280dcd5 7 MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
schematic 0:dc9bb280dcd5 8
schematic 0:dc9bb280dcd5 9 // --- Set Serial Port
schematic 0:dc9bb280dcd5 10 Serial pc(USBTX, USBRX); // tx, rxSerial pc(USBTX, USBRX); // tx, rx
schematic 0:dc9bb280dcd5 11
schematic 0:dc9bb280dcd5 12 int main() {
schematic 0:dc9bb280dcd5 13
schematic 0:dc9bb280dcd5 14 //float aX;
schematic 0:dc9bb280dcd5 15 //float aY;
schematic 0:dc9bb280dcd5 16 float aZ;
schematic 0:dc9bb280dcd5 17
schematic 0:dc9bb280dcd5 18 //float z1;
schematic 0:dc9bb280dcd5 19 //float z2;
schematic 0:dc9bb280dcd5 20 //float diff;
schematic 0:dc9bb280dcd5 21
schematic 0:dc9bb280dcd5 22 // --- Baud rate setting
schematic 0:dc9bb280dcd5 23 pc.baud(115200);
schematic 0:dc9bb280dcd5 24 wait(1);
schematic 0:dc9bb280dcd5 25
schematic 0:dc9bb280dcd5 26 while(1) {
schematic 0:dc9bb280dcd5 27
schematic 0:dc9bb280dcd5 28 //aX = acc.getAccX();
schematic 0:dc9bb280dcd5 29 //aY = acc.getAccY();
schematic 0:dc9bb280dcd5 30 aZ = acc.getAccZ();
schematic 0:dc9bb280dcd5 31
schematic 0:dc9bb280dcd5 32 //sprintf(str, "%+6.*f", 4, val);
schematic 0:dc9bb280dcd5 33 //printf("val = %s.\n", str);
schematic 0:dc9bb280dcd5 34 //printf("%f\n", floatVal);
schematic 0:dc9bb280dcd5 35
schematic 0:dc9bb280dcd5 36
schematic 0:dc9bb280dcd5 37 pc.printf("Z:%f<EOF>\r\n",aZ);
schematic 0:dc9bb280dcd5 38
schematic 0:dc9bb280dcd5 39
schematic 0:dc9bb280dcd5 40 //wait(0.02);
schematic 0:dc9bb280dcd5 41 }
schematic 0:dc9bb280dcd5 42 }