![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
a cool bubble game
Dependencies: DmTouch_UniGraphic UniGraphic mbed
Fork of DAY_8_miniproject by
Diff: accel_sensor.cpp
- Revision:
- 2:b0e371e6bbfe
- Parent:
- 1:7a145a5af9cd
--- a/accel_sensor.cpp Thu Jan 12 23:40:04 2017 +0000 +++ b/accel_sensor.cpp Thu Jan 12 23:41:56 2017 +0000 @@ -0,0 +1,28 @@ +#include "accel_sensor.h" + +void acceleration_n(void){ + cs=1; + acc.format(8,3); + acc.frequency(2000000); + cs=0; + acc.write(0x31); + acc.write(0x0B); + cs=1; + cs=0; + acc.write(0x2D); + acc.write(0x08); + cs=1; + + while(1){ + wait(0.2); + cs=0; + acc.write(0x80|0x40|0x32); + for (int i = 0; i <=5;i++){ + buffer[i]=acc.write(0x00)); + } + cs=1; + data[0]=buffer[1]<<8|buffer[0]; + data[1]=buffer[3]<<8|buffer[2]; + x=0.004*data[0]; y=0.004*data[1]; + } + } \ No newline at end of file