jacket

Dependencies:   WS2812 mbed

Committer:
elmoow
Date:
Wed Aug 16 23:25:21 2017 +0000
Revision:
0:6b4d6c5872b5
jacket

Who changed what in which revision?

UserRevisionLine numberNew contents of line
elmoow 0:6b4d6c5872b5 1 /*
elmoow 0:6b4d6c5872b5 2 fire colors
elmoow 0:6b4d6c5872b5 3 EBC137 E38C2D DB4C2C 771E10 48110C
elmoow 0:6b4d6c5872b5 4 */
elmoow 0:6b4d6c5872b5 5
elmoow 0:6b4d6c5872b5 6
elmoow 0:6b4d6c5872b5 7 #include "mbed.h"
elmoow 0:6b4d6c5872b5 8 #include "WS2812.h"
elmoow 0:6b4d6c5872b5 9
elmoow 0:6b4d6c5872b5 10 //#define LED_RGB D4
elmoow 0:6b4d6c5872b5 11
elmoow 0:6b4d6c5872b5 12 #define LED_RGB1 D1
elmoow 0:6b4d6c5872b5 13 #define LED_RGB2 D2
elmoow 0:6b4d6c5872b5 14 #define LED_RGB3 D3
elmoow 0:6b4d6c5872b5 15 #define LED_RGB4 D4
elmoow 0:6b4d6c5872b5 16 #define LED_RGB5 D5
elmoow 0:6b4d6c5872b5 17 #define LED_RGB6 D6
elmoow 0:6b4d6c5872b5 18
elmoow 0:6b4d6c5872b5 19
elmoow 0:6b4d6c5872b5 20
elmoow 0:6b4d6c5872b5 21
elmoow 0:6b4d6c5872b5 22 const int N=200;
elmoow 0:6b4d6c5872b5 23
elmoow 0:6b4d6c5872b5 24 WS2812 RGB1(LED_RGB1, N);
elmoow 0:6b4d6c5872b5 25 WS2812 RGB2(LED_RGB2, N);
elmoow 0:6b4d6c5872b5 26 WS2812 RGB3(LED_RGB3, N);
elmoow 0:6b4d6c5872b5 27 WS2812 RGB4(LED_RGB4, N);
elmoow 0:6b4d6c5872b5 28 WS2812 RGB5(LED_RGB5, N);
elmoow 0:6b4d6c5872b5 29 WS2812 RGB6(LED_RGB6, N);
elmoow 0:6b4d6c5872b5 30
elmoow 0:6b4d6c5872b5 31
elmoow 0:6b4d6c5872b5 32 uint32_t colors[N];
elmoow 0:6b4d6c5872b5 33 uint32_t firecolors[6]={0x000000,0xEBC137,0xE38C2D,0xDB4C2C,0x771E10,0x48110C};
elmoow 0:6b4d6c5872b5 34 uint32_t galaxycolors[5]={0x0E0C03,0x0E0802,0x0D0402,0x070101,0x040100};//{0x111111,0x111111,0x111111,0x111111,0x111111};//{0x003a65,0x009085,0xffffff,0x960088,0x000000};
elmoow 0:6b4d6c5872b5 35
elmoow 0:6b4d6c5872b5 36 DigitalOut myled(LED1);
elmoow 0:6b4d6c5872b5 37
elmoow 0:6b4d6c5872b5 38
elmoow 0:6b4d6c5872b5 39 int main() {
elmoow 0:6b4d6c5872b5 40 for(int i=0;i<N;i++){
elmoow 0:6b4d6c5872b5 41 colors[i]=rand();
elmoow 0:6b4d6c5872b5 42 }
elmoow 0:6b4d6c5872b5 43 for(int i=0;i<N;i++){
elmoow 0:6b4d6c5872b5 44 colors[i]=galaxycolors[rand()%5];
elmoow 0:6b4d6c5872b5 45 }
elmoow 0:6b4d6c5872b5 46
elmoow 0:6b4d6c5872b5 47 while(1) {
elmoow 0:6b4d6c5872b5 48 myled = 1; // LED is ON
elmoow 0:6b4d6c5872b5 49 wait(0.1); // 200 ms
elmoow 0:6b4d6c5872b5 50 myled = 0; // LED is OFF
elmoow 0:6b4d6c5872b5 51 wait(0.1); // 1 sec
elmoow 0:6b4d6c5872b5 52
elmoow 0:6b4d6c5872b5 53
elmoow 0:6b4d6c5872b5 54 colors[N-1]=colors[N-2]+0x010101;
elmoow 0:6b4d6c5872b5 55 for(int i=0;i<N;i++){
elmoow 0:6b4d6c5872b5 56 if((rand()%8)==6){
elmoow 0:6b4d6c5872b5 57 colors[i]= galaxycolors[rand()%5];
elmoow 0:6b4d6c5872b5 58 }
elmoow 0:6b4d6c5872b5 59 }
elmoow 0:6b4d6c5872b5 60
elmoow 0:6b4d6c5872b5 61 RGB1.sendColors(colors);
elmoow 0:6b4d6c5872b5 62 RGB2.sendColors(colors);
elmoow 0:6b4d6c5872b5 63 RGB3.sendColors(colors);
elmoow 0:6b4d6c5872b5 64 RGB4.sendColors(colors);
elmoow 0:6b4d6c5872b5 65 RGB5.sendColors(colors);
elmoow 0:6b4d6c5872b5 66 RGB6.sendColors(colors);
elmoow 0:6b4d6c5872b5 67
elmoow 0:6b4d6c5872b5 68
elmoow 0:6b4d6c5872b5 69 }
elmoow 0:6b4d6c5872b5 70 }