test

Dependencies:   mbed MMA8452Q

Fork of HelloWorld by Simon Ford

Revision:
10:386a3a12f3cf
Parent:
9:f36f1506a840
Child:
11:5499b22fd01e
--- a/main.cpp	Wed Aug 30 20:09:39 2017 +0000
+++ b/main.cpp	Wed Aug 30 20:39:45 2017 +0000
@@ -1,11 +1,12 @@
 #include "mbed.h"    
 #include "MMA8452Q.h"
 
-          
- //hello
 Serial pc(USBTX, USBRX); // tx, rx
+SPI accel(p11,p12,p13);
+DigitalOut cs(p14);
+// Communication I2C
 //I2C comI2C(p9,p10); // sda, scl
-// Communication I2C
+
 int main() {
     
      float x, y, z ;
@@ -18,7 +19,16 @@
          z = acc.getAccZ() ;
          printf("X[%.2f] Y[%.2f] Z[%.2f]\n",x, y, z) ;
          wait(0.1);
-         }
+         
+         int numx = (int)x;
+         
+         cs = 0;
+         accel.write(numx);
+         cs = 1;
+         wait(0.2);
+         cs = 0;
+         wait(1); 
+        }
 }