This program displays x and y axis value on LCD

Dependencies:   C12832 MMA7660 mbed

Files at this revision

API Documentation at this revision

Comitter:
dwijaybane
Date:
Sat Oct 10 07:09:20 2015 +0000
Parent:
0:2cb49169252d
Commit message:
comments updated

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Tue Oct 06 10:17:20 2015 +0000
+++ b/main.cpp	Sat Oct 10 07:09:20 2015 +0000
@@ -1,18 +1,20 @@
-#include "mbed.h"
-#include "MMA7660.h"
-#include "C12832.h"
+#include "mbed.h"       // Basic Library required for onchip peripherals
+#include "MMA7660.h"    // Library for MMA7660 3-axis accelerometer
+#include "C12832.h"     // Library for SPI based LCD
  
-C12832 lcd(p5, p7, p6, p8, p11);
-MMA7660 MMA(p28, p27);
+/* Create Objects */  
+C12832 lcd(p5, p7, p6, p8, p11);    // Initialize lcd object with SPI pins
+MMA7660 MMA(p28, p27);              // Initialize I2C pins for MMA object
 
+/* Main Program */
 int main() {  
-    lcd.cls();
-    lcd.locate(0,3);
-    lcd.printf("Accelerometer Value:");
+    lcd.cls();              // Clear LCD Screen
+    lcd.locate(0,3);        // Start from x=0 and y=3 pixels
+    lcd.printf("Accelerometer Value:"); // Display Accelerometer msg on LCD
         
     while(1) {
-        lcd.locate(0,15);
-        lcd.printf("x=%5.4f  y=%5.4f",MMA.x(),MMA.y());
-        wait(0.1);
+        lcd.locate(0,15);   // Start from x=0 and y=15 pixels
+        lcd.printf("x=%5.4f  y=%5.4f",MMA.x(),MMA.y()); // Print x and y values max will be 1
+        wait(0.1);          // 1 sec delay
     }
 }