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

Files at this revision

API Documentation at this revision

Comitter:
jewirth
Date:
Fri May 30 10:23:44 2014 +0000
Child:
1:609d9df3ffdc
Commit message:
initial commit for my RGB-LED demo

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
--- /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
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri May 30 10:23:44 2014 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/0b3ab51c8877
\ No newline at end of file