Example code for driving the WS2801 LEDs

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
bridadan
Date:
Thu May 28 14:28:24 2015 +0000
Commit message:
Initial Commit

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 4d2472ee7b7c main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu May 28 14:28:24 2015 +0000
@@ -0,0 +1,33 @@
+#include "mbed.h"
+
+#define LED_COUNT 22
+DigitalOut gpo(D0);
+DigitalOut led(LED_RED);
+SPI spi(D11, D12, D13);
+
+
+void writeCol(int r, int g, int b) {
+    for (int i = 0; i < LED_COUNT; i++) {
+        spi.write(r);
+        spi.write(g);
+        spi.write(b);
+    }
+}
+
+int main()
+{
+    int r = 0;
+    
+    while(true) {
+        
+        for (int i = 0; i <= 0xFF; i++) {
+            writeCol(i, 0, 0);
+            wait(0.01);
+        }
+        
+        for (int i = 0xFF; i >= 0x00; i--) {
+            writeCol(i, 0, 0);
+            wait(0.01);
+        }
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r 4d2472ee7b7c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Thu May 28 14:28:24 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/dbbf35b96557
\ No newline at end of file