SPI and I2C interfaces, displaying accelerometer data on the LCD

Dependencies:   mbed C12832 MMA7660

Files at this revision

API Documentation at this revision

Comitter:
kaushalpkk
Date:
Thu Mar 21 10:36:58 2019 +0000
Parent:
3:2db94ee076ee
Commit message:
...

Changed in this revision

MMA7660.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Thu Mar 21 10:36:58 2019 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/Sissors/code/MMA7660/#36a163511e34
--- 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();
     }
 }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+