Extra Program

Dependencies:   C12832 MMA7660

Revision:
7:adfd46d88d34
Parent:
6:f8cb706c480c
Child:
8:f66441d6b175
--- a/main.cpp	Tue Sep 19 15:25:01 2017 +0000
+++ b/main.cpp	Mon Feb 10 09:42:11 2020 +0000
@@ -6,14 +6,19 @@
 
 int main()
 {
-    int j=0;
-    lcd.cls();
-    lcd.locate(0,3);
-    lcd.printf("mbed application shield!");
+    AnalogIn pot1 (A0);
+    AnalogIn pot2 (A1);
+    PwmOut r (D5);
+    PwmOut g (D8);
+    PwmOut b (D9);
 
     while(true) {   // this is the third thread
-        lcd.locate(0,15);
-        lcd.printf("Counting : %d",j++);
-        wait(1.0);
+        
+            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);
+        wait(0.2);
     }
 }