forked from marmilicious/FastLED_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHex_colors_to_function.ino
62 lines (51 loc) · 1.6 KB
/
Hex_colors_to_function.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
//***************************************************************
// Example of defining a CRGB color using Hex,
// and passing that to a function.
//
// Marc Miller, Feb 2017
//***************************************************************
#include "FastLED.h"
#define DATA_PIN 11
#define CLK_PIN 13
#define LED_TYPE LPD8806
#define COLOR_ORDER GRB
#define NUM_LEDS 32
#define BRIGHTNESS 50
CRGB leds[NUM_LEDS];
#define MGPu CRGB(0x8010ff) // Mardi Gras Purple
#define MGGr CRGB(0x2cb004) // Green
#define MGGo CRGB(0xff4a00) // Gold
//---------------------------------------------------------------
void setup() {
Serial.begin(115200); // Allows serial monitor output (check baud rate)
delay(3000); // 3 second delay for recovery
//FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.addLeds<LED_TYPE,DATA_PIN,CLK_PIN,COLOR_ORDER>(leds, NUM_LEDS).setCorrection(TypicalLEDStrip);
FastLED.setBrightness(BRIGHTNESS);
}
//---------------------------------------------------------------
void loop() {
cylon(MGPu); // Purple. (Call cylon function with this color.)
cylon(MGGr); // Green
cylon(MGGo); // Gold
}
//---------------------------------------------------------------
void fadeall() {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i].nscale8(250);
}
}
void cylon(CRGB streakcolor) {
for (int i = 0; i < NUM_LEDS; i++) {
leds[i] = streakcolor;
FastLED.show();
fadeall();
delay(10);
}
for (int i = (NUM_LEDS) - 1; i >= 0; i--) {
leds[i] = streakcolor;
FastLED.show();
fadeall();
delay(10);
}
}