Brian Daniels
/
ws2801
Example code for driving the WS2801 LEDs
Diff: main.cpp
- Revision:
- 0:4d2472ee7b7c
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