Brian Daniels
/
ws2801
Example code for driving the WS2801 LEDs
main.cpp
- Committer:
- bridadan
- Date:
- 2015-05-28
- Revision:
- 0:4d2472ee7b7c
File content as of revision 0:4d2472ee7b7c:
#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); } } }