prueba comunicación i^2c

Dependencies:   mbed

Fork of i2ctry by César Fierro

Revision:
0:b52c6d67b596
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/i2c.cpp	Sat May 16 21:37:52 2015 +0000
@@ -0,0 +1,32 @@
+#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);
+    }
+    
+}
\ No newline at end of file