-
Notifications
You must be signed in to change notification settings - Fork 46
/
custom_color_array.ino
73 lines (56 loc) · 1.81 KB
/
custom_color_array.ino
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//***************************************************************
// Example of assigning colors from a custom color array.
//
// Marc Miller, Aug 2018
//***************************************************************
#include "FastLED.h"
#define LED_TYPE LPD8806
#define DATA_PIN 11
#define CLOCK_PIN 13
#define NUM_LEDS 32
#define COLOR_ORDER GRB
#define BRIGHTNESS 255
CRGB leds[NUM_LEDS];
uint8_t colorPick;
// Custom color array
CRGB colorArray[] = {
CRGB::Red,
CRGB::Grey,
CRGB::Blue,
CRGB(0,255,0),
CHSV(195,255,255),
};
//---------------------------------------------------------------
void setup() {
Serial.begin(115200); // Allows serial monitor output (check your baud rate)
delay(2000); // Startup delay
FastLED.addLeds<LED_TYPE,DATA_PIN,CLOCK_PIN,COLOR_ORDER>(leds, NUM_LEDS); // ***For strips using Clock.
//FastLED.addLeds<LED_TYPE,DATA_PIN>(leds, NUM_LEDS); // ***For Clock-less strips.
FastLED.setBrightness(BRIGHTNESS);
}
//---------------------------------------------------------------
void loop() {
//pick a random color from the custom color array
colorPick = random8( sizeof(colorArray) / sizeof(colorArray[0]) );
for (uint8_t i = 0; i < NUM_LEDS; i++) {
leds[i] = colorArray[colorPick];
FastLED.show();
delay(50);
fadeToBlackBy(leds, NUM_LEDS, 220);
}
}//end_main_loop
//---------------------------------------------------------------
/*
Not used here in this code, but here are examles of how you can
assign custom color names (using RGB, HSV, web names, or hex)
which can later be used in your code.
CRGB myColorA (0,128,128);
CHSV myColorB (160,128,255);
CRGB myColorC = CHSV(42,128,255);
CRGB myColorD = CRGB::Purple;
CRGB myColorE = 0xE1A024;
#define myColorF CRGB(128,0,255)
#define myColorG 0x902C02
Then in your code you can do:
leds[i] = myColorA;
*/