2 buttons and 2 switches, compiles, not tested

Dependencies:   mbed C12832 MMA7660 USBDevice

Revision:
10:150f8d03f18d
Parent:
9:66681432403a
Child:
11:73e8c1bb5467
Child:
21:53426ae5b7b1
--- a/main.cpp	Tue Oct 08 20:09:43 2019 +0000
+++ b/main.cpp	Thu Oct 10 16:55:08 2019 +0000
@@ -1,6 +1,7 @@
 #include "mbed.h"
 #include "USBKeyboard.h"
 #include "MMA7660.h"
+#include "C12832.h"
 
 
 
@@ -12,7 +13,7 @@
 DigitalInOut SCL(p27);
 DigitalInOut SDA(p28);
 
-AnalogIn x(p15),y(p16);
+
 
 AnalogOut Zaxis_p (USBKeyboard);
 AnalogOut Zaxis_n (USBKeyboard);
@@ -21,31 +22,43 @@
 AnalogOut Xaxis_p (USBKeyboard);
 AnalogOut Xaxis_n (USBKeyboard);
 
+C12832      LCD (p5,p7,p6,p8,p11);
 
 
-int main() 
-{
-float X1,Y1,Z1;                //variables to store acceleration values in X and Y
-      
-while(1)
+int main()
 {
-    X1=x.read();            //read acceleration values in x direction
-    Y1=y.read();            //read acceleration values  in y direction
-    //Z1=z.read();
-          
-    if(X1>0.55)             // comparison with threshold values  for positive X
-    keyboard.printf("a\0");   // send a specified token(command)
-    else if(X1<0.47)        // comparison with threshold values  for negative X
-    keyboard.printf("d\0");   
-    if(Y1>0.55)             // comparison with threshold values  for negative Y
-    keyboard.printf("s\0");   
-    else if(Y1<0.47)        // comparison with threshold values  for positive Y
-    keyboard.printf("w\0");
- //   if(Z1>0.55)
- //   keyboard.printf("esc\0");
- //   else if(Z1<0.47)
- //   keyboard.printf("enter\0");   
-    wait(0.1);
+    float X1,Y1,Z1;                //variables to store acceleration values in X and Y
+
+    while(1) {
+        X1 = MMA.x ();
+        Y1 = MMA.y ();
+        Z1 = MMA.z ();
+        
+        LCD.cls ();
+        LCD.locate (0,0);
+        LCD.printf("X Axis: %f", X1);
+        LCD.locate (0,10);
+        LCD.printf("Y Axis: %f", Y1);
+        LCD.locate (0,20);
+        LCD.printf("Z Axis: %f", Z1);
+        
+/*
+        if(X1>0.55)             // comparison with threshold values  for positive X
+            keyboard.printf("a\0");   // send a specified token(command)
+        else if(X1<0.47)        // comparison with threshold values  for negative X
+            keyboard.printf("d\0");
+        if(Y1>0.55)             // comparison with threshold values  for negative Y
+            keyboard.printf("s\0");
+        else if(Y1<0.47)        // comparison with threshold values  for positive Y
+            keyboard.printf("w\0");
+//   if(Z1>0.55)
+//   keyboard.printf("esc\0");
+//   else if(Z1<0.47)
+//   keyboard.printf("enter\0");
+        wait(0.1);
+  */
+  
+  
     }
-  
+
 }
\ No newline at end of file