Demo for Accel

Dependencies:   MMA8451Q mbed

Fork of FRDM_MMA8451Q by Sivasai Praneeth Nanduri

Committer:
chris
Date:
Fri Oct 12 11:02:58 2012 +0000
Revision:
2:41db78380a6e
Parent:
0:d9c1551e1fdc
Child:
3:f2d3e041d8f2
Updated the hello world example in doxygen

Who changed what in which revision?

UserRevisionLine numberNew contents of line
chris 2:41db78380a6e 1 #include "mbed.h"
chris 2:41db78380a6e 2 #include "MMA8451Q.h"
chris 2:41db78380a6e 3
chris 2:41db78380a6e 4 #define MMA8451_I2C_ADDRESS (0x1d<<1)
chris 2:41db78380a6e 5
chris 2:41db78380a6e 6 int main(void) {
chris 2:41db78380a6e 7 DigitalOut led(LED_GREEN);
chris 2:41db78380a6e 8 MMA8451Q acc(P_E25, P_E24, MMA8451_I2C_ADDRESS);
chris 2:41db78380a6e 9 printf("WHO AM I: 0x%2X\r\n", acc.getWhoAmI());
chris 2:41db78380a6e 10
chris 2:41db78380a6e 11 while (true) {
chris 2:41db78380a6e 12 printf("-----------\r\n");
chris 2:41db78380a6e 13 printf("acc_x: %.3f\r\n", acc.getAccX());
chris 2:41db78380a6e 14 printf("acc_y: %.3f\r\n", acc.getAccY());
chris 2:41db78380a6e 15 printf("acc_z: %.3f\r\n", acc.getAccZ());
chris 2:41db78380a6e 16
chris 2:41db78380a6e 17 wait(1);
chris 2:41db78380a6e 18 led = !led;
chris 2:41db78380a6e 19 }
chris 2:41db78380a6e 20 }