This FRDM-KL25Z demo will blink the RGB LED with all colors. The touch slider input controls the blinking frequency. The UART output shows the touch slider input.

Dependencies:   TSI mbed

Revision:
0:6f33cc0cd2ac
Child:
1:609d9df3ffdc
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri May 30 10:23:44 2014 +0000
@@ -0,0 +1,28 @@
+#include "mbed.h"
+
+#define LED_ON                  0
+#define LED_OFF                 1
+#define RGB_COMPONENTS          3
+#define RGB_COLORS              ((int) pow(2 *1.0, RGB_COMPONENTS *1.0))
+#define DELAY                   0.5
+
+DigitalOut led_rgb_red(LED1);   // red
+DigitalOut led_rgb_grn(LED2);   // green
+DigitalOut led_rgb_blu(LED3);   // blue
+
+DigitalOut led_rgb[RGB_COMPONENTS] = {led_rgb_red, led_rgb_grn, led_rgb_blu};
+
+int main()
+{
+    // turn all LEDs off
+    for (int i=0; i<RGB_COMPONENTS; i++)
+        led_rgb[i] = LED_OFF;
+    
+    while(1)
+    {
+        // show all colors
+        for (int i=0; i<RGB_COLORS; i++, wait(DELAY))   // for each possible color
+            for (int j=0; j<RGB_COMPONENTS; j++)            // for each LED component
+                led_rgb[j] = ( i & 1<<j ) ? LED_ON : LED_OFF;   // set LED component according to active color
+    }
+}