Extra Program

Dependencies:   C12832 MMA7660

Files at this revision

API Documentation at this revision

Comitter:
deboerengamer
Date:
Mon Feb 10 10:01:14 2020 +0000
Parent:
7:adfd46d88d34
Commit message:
Acceleration

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
diff -r adfd46d88d34 -r f66441d6b175 MMA7660.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MMA7660.lib	Mon Feb 10 10:01:14 2020 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/Sissors/code/MMA7660/#36a163511e34
diff -r adfd46d88d34 -r f66441d6b175 main.cpp
--- a/main.cpp	Mon Feb 10 09:42:11 2020 +0000
+++ b/main.cpp	Mon Feb 10 10:01:14 2020 +0000
@@ -1,24 +1,22 @@
 #include "mbed.h"
 #include "C12832.h"
+#include "MMA7660.h"
 
 // Using Arduino pin notation
 C12832 lcd(D11, D13, D12, D7, D10);
 
 int main()
 {
-    AnalogIn pot1 (A0);
-    AnalogIn pot2 (A1);
+    MMA7660 MMA(D14,D15);
     PwmOut r (D5);
     PwmOut g (D8);
     PwmOut b (D9);
 
     while(true) {   // this is the third thread
         
-            r = 1.0 - ((pot1 < 1.0) ? 1.0 - pot1 : (pot1 > 2.0) ? pot1 - 2.0 : 0.0);
-            g = 1.0 - ((pot1 < 1.0) ? pot1 : (pot1 > 2.0) ? 0.0 : 2.0 - pot1);
-            b = 1.0 - ((pot1 < 1.0) ? 0.0 : (pot1 > 2.0) ? 3.0 - pot1 : pot1 - 1.0);  ;
-            lcd.locate(0,3);
-            lcd.printf("Pot 2 = %.2f", (float)pot2);
+            r = MMA.x();
+            g = MMA.y();
+            b = MMA.z();
         wait(0.2);
     }
 }