FastLED
3.9.15
Loading...
Searching...
No Matches
ColorTemperature.ino
Go to the documentation of this file.
1
4
5
#include <
FastLED.h
>
6
7
#define LED_PIN 3
8
9
// Information about the LED strip itself
10
#define NUM_LEDS 60
11
#define CHIPSET WS2811
12
#define COLOR_ORDER GRB
13
CRGB
leds
[
NUM_LEDS
];
14
15
#define BRIGHTNESS 128
16
17
18
// FastLED provides two color-management controls:
19
// (1) color correction settings for each LED strip, and
20
// (2) master control of the overall output 'color temperature'
21
//
22
// THIS EXAMPLE demonstrates the second, "color temperature" control.
23
// It shows a simple rainbow animation first with one temperature profile,
24
// and a few seconds later, with a different temperature profile.
25
//
26
// The first pixel of the strip will show the color temperature.
27
//
28
// HELPFUL HINTS for "seeing" the effect in this demo:
29
// * Don't look directly at the LED pixels. Shine the LEDs aganst
30
// a white wall, table, or piece of paper, and look at the reflected light.
31
//
32
// * If you watch it for a bit, and then walk away, and then come back
33
// to it, you'll probably be able to "see" whether it's currently using
34
// the 'redder' or the 'bluer' temperature profile, even not counting
35
// the lowest 'indicator' pixel.
36
//
37
//
38
// FastLED provides these pre-conigured incandescent color profiles:
39
// Candle, Tungsten40W, Tungsten100W, Halogen, CarbonArc,
40
// HighNoonSun, DirectSunlight, OvercastSky, ClearBlueSky,
41
// FastLED provides these pre-configured gaseous-light color profiles:
42
// WarmFluorescent, StandardFluorescent, CoolWhiteFluorescent,
43
// FullSpectrumFluorescent, GrowLightFluorescent, BlackLightFluorescent,
44
// MercuryVapor, SodiumVapor, MetalHalide, HighPressureSodium,
45
// FastLED also provides an "Uncorrected temperature" profile
46
// UncorrectedTemperature;
47
48
#define TEMPERATURE_1 Tungsten100W
49
#define TEMPERATURE_2 OvercastSky
50
51
// How many seconds to show each temperature before switching
52
#define DISPLAYTIME 20
53
// How many seconds to show black between switches
54
#define BLACKTIME 3
55
56
void
loop
()
57
{
58
// draw a generic, no-name rainbow
59
static
uint8_t starthue = 0;
60
fill_rainbow
(
leds
+ 5,
NUM_LEDS
- 5, --starthue, 20);
61
62
// Choose which 'color temperature' profile to enable.
63
uint8_t secs = (millis() / 1000) % (
DISPLAYTIME
* 2);
64
if
( secs <
DISPLAYTIME
) {
65
FastLED
.setTemperature(
TEMPERATURE_1
);
// first temperature
66
leds
[0] =
TEMPERATURE_1
;
// show indicator pixel
67
}
else
{
68
FastLED
.setTemperature(
TEMPERATURE_2
);
// second temperature
69
leds
[0] =
TEMPERATURE_2
;
// show indicator pixel
70
}
71
72
// Black out the LEDs for a few secnds between color changes
73
// to let the eyes and brains adjust
74
if
( (secs %
DISPLAYTIME
) <
BLACKTIME
) {
75
memset8
(
leds
, 0,
NUM_LEDS
*
sizeof
(
CRGB
));
76
}
77
78
FastLED
.show();
79
FastLED
.delay(8);
80
}
81
82
void
setup
() {
83
delay( 3000 );
// power-up safety delay
84
// It's important to set the color correction for your LED strip here,
85
// so that colors can be more accurately rendered through the 'temperature' profiles
86
FastLED
.addLeds<
CHIPSET
,
LED_PIN
,
COLOR_ORDER
>(
leds
,
NUM_LEDS
).setCorrection(
TypicalSMD5050
);
87
FastLED
.setBrightness(
BRIGHTNESS
);
88
}
89
leds
CRGB leds[NUM_LEDS]
Definition
Apa102.ino:11
NUM_LEDS
#define NUM_LEDS
Definition
Apa102.ino:6
BRIGHTNESS
#define BRIGHTNESS
Definition
Blur.ino:8
COLOR_ORDER
#define COLOR_ORDER
Definition
ColorPalette.ino:11
LED_PIN
#define LED_PIN
Definition
ColorPalette.ino:7
setup
void setup()
Definition
ColorTemperature.ino:82
TEMPERATURE_1
#define TEMPERATURE_1
Definition
ColorTemperature.ino:48
TEMPERATURE_2
#define TEMPERATURE_2
Definition
ColorTemperature.ino:49
CHIPSET
#define CHIPSET
Definition
ColorTemperature.ino:11
BLACKTIME
#define BLACKTIME
Definition
ColorTemperature.ino:54
DISPLAYTIME
#define DISPLAYTIME
Definition
ColorTemperature.ino:52
loop
void loop()
Definition
ColorTemperature.ino:56
fill_rainbow
void fill_rainbow(CRGB *all_leds)
Definition
Esp32S3I2SDemo.ino:189
FastLED
CFastLED FastLED
Global LED strip management instance.
Definition
FastLED.cpp:58
FastLED.h
central include file for FastLED, defines the CFastLED class/object
TypicalSMD5050
@ TypicalSMD5050
Typical values for SMD5050 LEDs.
Definition
color.h:17
memset8
void * memset8(void *ptr, uint8_t value, uint16_t num)
Faster alternative to memset() on AVR.
CRGB
Representation of an RGB pixel (Red, Green, Blue)
Definition
crgb.h:55
examples
ColorTemperature
ColorTemperature.ino
Generated on Thu May 29 2025 04:44:56 for FastLED by
1.13.2