A simple test of the WS2812 library on K64F.

Dependencies:   PixelArray WS2812 mbed

Fork of WS2812_Example by Brian Daniels

Committer:
mochen
Date:
Wed Jun 14 01:46:42 2017 +0000
Revision:
3:a0545942de4f
Parent:
2:cb82a3dc4031
Simplified colors to make a basic test.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bridadan 0:12cb6f0c2788 1 #include "mbed.h"
bridadan 0:12cb6f0c2788 2 #include "WS2812.h"
bridadan 0:12cb6f0c2788 3 #include "PixelArray.h"
bridadan 0:12cb6f0c2788 4
mochen 3:a0545942de4f 5 #define WS2812_BUF 3
bridadan 2:cb82a3dc4031 6 #define NUM_COLORS 6
mochen 3:a0545942de4f 7 #define NUM_LEDS_PER_COLOR 1
bridadan 0:12cb6f0c2788 8
bridadan 0:12cb6f0c2788 9 PixelArray px(WS2812_BUF);
bridadan 0:12cb6f0c2788 10
bridadan 2:cb82a3dc4031 11 // See the program page for information on the timing numbers
bridadan 1:e04a0ecefa29 12 // The given numbers are for the K64F
mochen 3:a0545942de4f 13 WS2812 ws(D6, WS2812_BUF, 0, 5, 5, 0);
bridadan 0:12cb6f0c2788 14
bridadan 0:12cb6f0c2788 15 int main()
bridadan 0:12cb6f0c2788 16 {
mochen 3:a0545942de4f 17 px.Set(0, 0);
mochen 3:a0545942de4f 18 px.Set(1, 0x00ff00);
mochen 3:a0545942de4f 19 px.Set(2, 0x00ee00);
bridadan 0:12cb6f0c2788 20
bridadan 0:12cb6f0c2788 21 // Now the buffer is written, rotate it
bridadan 0:12cb6f0c2788 22 // by writing it out with an increasing offset
bridadan 0:12cb6f0c2788 23 while (1) {
mochen 3:a0545942de4f 24 ws.write(px.getBuf());
bridadan 0:12cb6f0c2788 25 wait(0.075);
bridadan 0:12cb6f0c2788 26 }
bridadan 0:12cb6f0c2788 27
bridadan 0:12cb6f0c2788 28 }