Slightly cooler slider demo for FRDM-KL25Z -- shows one color when not touched and then blends two other colors as you slide your finger along the touch sensor.

Dependencies:   mbed tsi_sensor

Revision:
0:e48517b9b7e4
diff -r 000000000000 -r e48517b9b7e4 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Apr 15 05:09:33 2014 +0000
@@ -0,0 +1,35 @@
+#include "mbed.h"
+#include "tsi_sensor.h"
+
+/* This defines will be replaced by PinNames soon */
+#if defined (TARGET_KL25Z) || defined (TARGET_KL46Z)
+  #define ELEC0 9
+  #define ELEC1 10
+#elif defined (TARGET_KL05Z)
+  #define ELEC0 9
+  #define ELEC1 8
+#else
+  #error TARGET NOT DEFINED
+#endif
+
+int main(void) {
+    PwmOut led_r(LED_RED);
+    PwmOut led_g(LED_GREEN);
+    PwmOut led_b(LED_BLUE);
+    TSIAnalogSlider tsi(ELEC0, ELEC1, 40);
+    
+    while (true) {
+        float f=tsi.readPercentage();
+        if (f<.05)
+        {
+        led_b=0.0;
+        led_g=led_r=1.0;
+        } else
+            {
+            led_b=1.0;
+            led_r= 1.0 - f;
+            led_g = f;
+            }
+        wait(0.1);
+    }
+}