Gustavo Esteves / Mbed 2 deprecated Questao_3_Slide_Led_Cores

Dependencies:   mbed tsi_sensor

Fork of frdm_tsi_slider by Freescale

Files at this revision

API Documentation at this revision

Comitter:
GustavoRPE
Date:
Wed May 18 19:44:16 2016 +0000
Parent:
2:b13f658fd99f
Commit message:
teste 3

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r b13f658fd99f -r 900d47561319 main.cpp
--- a/main.cpp	Sun Feb 23 18:32:55 2014 +0000
+++ b/main.cpp	Wed May 18 19:44:16 2016 +0000
@@ -12,12 +12,59 @@
   #error TARGET NOT DEFINED
 #endif
 
+
+
 int main(void) {
-    PwmOut led(LED_GREEN);
-    TSIAnalogSlider tsi(ELEC0, ELEC1, 40);
+    PwmOut R(LED_RED);
+    PwmOut G(LED_GREEN);
+    PwmOut B(LED_BLUE);
+    TSIAnalogSlider tsi(ELEC0, ELEC1, 1);
+            R = 1;
+            G = 1;
+            B = 1;
     
     while (true) {
-        led = 1.0 - tsi.readPercentage();
-        wait(0.1);
+        //led = 1.0 - tsi.readPercentage();
+        int x = tsi.readPercentage()*100;
+        
+        if (x>1 && x<20) { //High Temperature
+             //- tsi.readPercentage();
+            R = 0;
+            G = 1;
+            B = 1;
+            wait(0.1);
+            }
+        if (x>20 && x<40) { //High Temperature
+            R = 1;
+            G = 0;
+            B = 1;
+            wait(0.1);
+            }
+        if (x>40 && x<60) { //High Temperature
+            R = 1;
+            G = 1;
+            B = 0;
+            wait(0.1);
+            }
+        if (x>60 && x<80) { //High Temperature
+            R = 0;
+            G = 0;
+            B = 1;
+            wait(0.1);
+            }               
+        if (x>80) { //High Temperature
+            R = 0;
+            G = 1;
+            B = 0;
+            wait(0.1);
+            }
+        if (x<1) { //High Temperature
+             //- tsi.readPercentage();
+            R = 1;
+            G = 1;
+            B = 1;
+            wait(0.1);
+            }                   
+
     }
 }