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

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
4180_1
Date:
Fri Apr 22 14:31:29 2011 +0000
Commit message:

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
diff -r 000000000000 -r fc7fc9c0cd67 main.cpp
--- /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);
+            }
+        }
+    }
+
+}
diff -r 000000000000 -r fc7fc9c0cd67 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Fri Apr 22 14:31:29 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912