SPI and I2C interfaces, displaying accelerometer data on the LCD

Dependencies:   mbed C12832 MMA7660

Revision:
4:14963dcf2861
Parent:
3:2db94ee076ee
--- a/main.cpp	Wed Feb 05 15:32:38 2014 +0000
+++ b/main.cpp	Thu Mar 21 10:36:58 2019 +0000
@@ -1,20 +1,63 @@
+//mbed library
 #include "mbed.h"
+//lcd library
 #include "C12832.h"
+//accelerometer library
+#include "MMA7660.h"
 
-
+//init LCD
 C12832 lcd(p5, p7, p6, p8, p11);
+// init accel
+MMA7660 MMA(p28, p27);
 
 int main()
 {
-    int j=0;
     lcd.cls();
     lcd.locate(0,3);
     lcd.printf("mbed application board!");
-
-    while(true) {   // this is the third thread
+    wait(5);
+    if (MMA.testConnection()) {
+        lcd.printf("the accelerometer is working OK");
+        wait(5);
+    }
+    while(true) {
+        lcd.locate(0,3);
+        lcd.printf("     X        Y       Z   \n");
         lcd.locate(0,15);
-        lcd.printf("Counting : %d",j);
-        j++;
-        wait(1.0);
+        lcd.printf("%.3f   %.3f  %.3f  \r", MMA.x(), MMA.y(), MMA.z());
+        wait(1);
+        lcd.cls();
     }
 }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+