Simple demo for a ShiftBrite RGB LED module that cycles through different colors.

Dependencies:   mbed

Revision:
0:fc7fc9c0cd67
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Fri Apr 22 14:31:29 2011 +0000
@@ -0,0 +1,39 @@
+#include "mbed.h"
+//ShiftBrite Demo
+DigitalOut latch(p15);
+DigitalOut enable(p16);
+//Cycles through different colors on RGB LED
+SPI spi(p11, p12, p13);
+//Use SPI hardware to write color values to LED driver chip
+void RGB_LED(int red, int green, int blue) {
+    unsigned int low_color=0;
+    unsigned int high_color=0;
+    high_color=(blue<<4)|((red&0x3C0)>>6);
+    low_color=(((red&0x3F)<<10)|(green));
+    spi.write(high_color);
+    spi.write(low_color);
+    latch=1;
+    latch=0;
+}
+
+int main() {
+    int red=0;
+    int green=0;
+    int blue=0;
+    spi.format(16,0);
+    spi.frequency(500000);
+    enable=0;
+    latch=0;
+    wait(2);
+    for (red = 0; red<50; red = red+10) {
+        for (blue = 0; blue<50; blue = blue+10) {
+            for (green = 0; green<50; green = green+10)
+
+            {
+                RGB_LED( red, green, blue);
+                wait(.25);
+            }
+        }
+    }
+
+}