![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
Driving
Dependencies: FSR LIS3DH USBDevice mbed
Fork of MMA8452_Demo by
main.cpp
- Committer:
- Ivannrush
- Date:
- 2014-10-17
- Revision:
- 8:46eab8a51f91
- Parent:
- 6:e3100f66ed6a
- Child:
- 9:cbce87f4f21f
File content as of revision 8:46eab8a51f91:
#include "mbed.h" #include "MMA8452.h" //Using MMA8452 accelerometer. SDA on 28, SCL on 27. Writes gravities to the screen. //Also brightens/dims LEDs 1-3 based on whether or not they are 'level'( 0 Gs) Serial pc(USBTX,USBRX); PwmOut led1(LED1); PwmOut led2(LED2); PwmOut led3(LED3); double x, y, z; MMA8452 acc(p28, p27, 100000); int main() { while(1) { acc.readXYZGravity(&x,&y,&z); pc.printf("x:%lf y:%lf z:%lf\r\n",x,y,z); led1 = abs(x); led2 = abs(y); led3 = abs(z); wait(.25); } }