Sarthak Gadre
/
lab6_AcceloPlotter
Plot of accelerometers axis
main.cpp@0:a0321e9eb2d8, 2016-12-03 (annotated)
- Committer:
- sarthakgadre
- Date:
- Sat Dec 03 11:18:16 2016 +0000
- Revision:
- 0:a0321e9eb2d8
Plot of accelerometer
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
sarthakgadre | 0:a0321e9eb2d8 | 1 | #include "mbed.h" |
sarthakgadre | 0:a0321e9eb2d8 | 2 | |
sarthakgadre | 0:a0321e9eb2d8 | 3 | #include"MMA8451Q.h" |
sarthakgadre | 0:a0321e9eb2d8 | 4 | #define MMA8451_I2C_ADDRESS (0x1d<<1) |
sarthakgadre | 0:a0321e9eb2d8 | 5 | Serial pc(USBTX,USBRX);//tx,rx |
sarthakgadre | 0:a0321e9eb2d8 | 6 | |
sarthakgadre | 0:a0321e9eb2d8 | 7 | int main() |
sarthakgadre | 0:a0321e9eb2d8 | 8 | { |
sarthakgadre | 0:a0321e9eb2d8 | 9 | int x=0; |
sarthakgadre | 0:a0321e9eb2d8 | 10 | int y=0; |
sarthakgadre | 0:a0321e9eb2d8 | 11 | int z=0; |
sarthakgadre | 0:a0321e9eb2d8 | 12 | MMA8451Q acc(PTE25,PTE24,MMA8451_I2C_ADDRESS); |
sarthakgadre | 0:a0321e9eb2d8 | 13 | |
sarthakgadre | 0:a0321e9eb2d8 | 14 | while(1) |
sarthakgadre | 0:a0321e9eb2d8 | 15 | { |
sarthakgadre | 0:a0321e9eb2d8 | 16 | x=1000*acc.getAccY(); |
sarthakgadre | 0:a0321e9eb2d8 | 17 | y=1000*acc.getAccX(); |
sarthakgadre | 0:a0321e9eb2d8 | 18 | z=1000*acc.getAccZ(); |
sarthakgadre | 0:a0321e9eb2d8 | 19 | |
sarthakgadre | 0:a0321e9eb2d8 | 20 | pc.printf("$%d %d %d;",x,y,z); |
sarthakgadre | 0:a0321e9eb2d8 | 21 | wait(0.1); |
sarthakgadre | 0:a0321e9eb2d8 | 22 | } |
sarthakgadre | 0:a0321e9eb2d8 | 23 | } |