![](/media/cache/group/default_image.jpg.50x50_q85.jpg)
test
Fork of HelloWorld by
Diff: main.cpp
- Revision:
- 7:32229ffff57e
- Parent:
- 6:62e39c103d12
- Child:
- 8:bb27936d2358
diff -r 62e39c103d12 -r 32229ffff57e main.cpp --- a/main.cpp Wed Aug 30 19:48:29 2017 +0000 +++ b/main.cpp Wed Aug 30 19:58:18 2017 +0000 @@ -1,5 +1,5 @@ #include "mbed.h" -#include "AccelSensor.h" + //hello Serial pc(USBTX, USBRX); // tx, rx @@ -7,14 +7,14 @@ // Communication I2C int main() { - AccelSensor senser(p9,p10); - - int degree; - senser.init(); - senser.active(); - senser.readData(°ree); - pc.printf("degree : %d", degree); - + comI2C.start(); + comI2C.write(0x3A); // A write to device 0x1D + comI2C.write(0x06); // Register to read from (acceleration in X) + comI2C.start(); // Need to send start condition here + comI2C.write(0x3B); // Read from device 0x1D + int c=comI2C.read(0); // Read the data with NACK + comI2C.stop(); + pc.printf("degree : %d", c); }