César Fierro
/
i2ctry
prueba comunicación i^2c
i2c.cpp
- Committer:
- fonz626
- Date:
- 2015-05-16
- Revision:
- 0:b52c6d67b596
File content as of revision 0:b52c6d67b596:
#include "mbed.h" #include "MMA8451Q.h" PinName const SDA = PTE25; PinName const SCL = PTE24; DigitalOut myled(LED2); #define MMA8451_I2C_ADDRESS (0x1d<<1) int main(){ MMA8451Q acc(SDA, SCL, MMA8451_I2C_ADDRESS); while (true) { float x, y, z; x = abs(acc.getAccX()); y = abs(acc.getAccY()); z = abs(acc.getAccZ()); if (x>0.5) { myled = 0; } else { myled = 1; } printf("%f",x); } }