This is a mouse which uses the integrated accelerometer

Dependencies:   MMA8451Q USBDevice mbed

Fork of FRDM_MMA8451Q by mbed official

Committer:
chris
Date:
Fri Oct 12 11:31:29 2012 +0000
Revision:
3:f2d3e041d8f2
Parent:
2:41db78380a6e
Child:
4:367de1084ea9
Changed axis readings to return a signed normalised float; Changed hello world program to change RGB LED

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 3:f2d3e041d8f2 6 MMA8451Q acc(P_E25, P_E24, MMA8451_I2C_ADDRESS);
chris 3:f2d3e041d8f2 7 PwmOut rled(LED_RED);
chris 3:f2d3e041d8f2 8 PwmOut gled(LED_GREEN);
chris 3:f2d3e041d8f2 9 PwmOut bled(LED_BLUE);
chris 3:f2d3e041d8f2 10
chris 2:41db78380a6e 11 int main(void) {
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 }