Prueba acelerometro - ejemplo recuperado

Dependencies:   MMA8451Q mbed

Fork of FRDM_MMA8451Q by Freescale

Committer:
chris
Date:
Fri Oct 12 11:35:21 2012 +0000
Revision:
4:367de1084ea9
Parent:
3:f2d3e041d8f2
Child:
5:bf5becf7469c
Pushed object declaration into main

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 4:367de1084ea9 6 int main(void) {
chris 4:367de1084ea9 7
chris 3:f2d3e041d8f2 8 MMA8451Q acc(P_E25, P_E24, MMA8451_I2C_ADDRESS);
chris 3:f2d3e041d8f2 9 PwmOut rled(LED_RED);
chris 3:f2d3e041d8f2 10 PwmOut gled(LED_GREEN);
chris 3:f2d3e041d8f2 11 PwmOut bled(LED_BLUE);
chris 3:f2d3e041d8f2 12
chris 3:f2d3e041d8f2 13 while (true) {
chris 3:f2d3e041d8f2 14 rled = 1.0 - abs(acc.getAccX());
chris 3:f2d3e041d8f2 15 gled = 1.0 - abs(acc.getAccY());
chris 3:f2d3e041d8f2 16 bled = 1.0 - abs(acc.getAccZ());
chris 3:f2d3e041d8f2 17 wait(0.1);
chris 2:41db78380a6e 18 }
chris 2:41db78380a6e 19 }