-
Notifications
You must be signed in to change notification settings - Fork 46
/
color_temperature_demo.ino
113 lines (103 loc) · 3.78 KB
/
color_temperature_demo.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//***************************************************************
// Demo to show all the predefined FastLED color temperatures.
// Fills the LED strip with white and then cycles through the temperatures.
//
// Marc Miller, Aug 2017
//***************************************************************
#include "FastLED.h"
#define DATA_PIN 11
#define CLOCK_PIN 13
#define LED_TYPE LPD8806
#define COLOR_ORDER GRB
#define NUM_LEDS 32
#define BRIGHTNESS 255
CRGB leds[NUM_LEDS];
#define DISPLAYTIME 4 //number of SECONDS to show each color temperature
#define BLACKOUTTIME 100 //number of MILLISECONDS to blackout between tempatures
uint8_t temp; //current tempature_# being displayed
//---------------------------------------------------------------
void setup() {
Serial.begin(115200); // Allows serial monitor output (check baud rate)
delay( 1500 ); // power-up safety delay
FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalSMD5050 );
FastLED.setBrightness( BRIGHTNESS );
FastLED.clear();
}
//---------------------------------------------------------------
//All the predefined FastLED color temperatures:
#define TEMPERATURE_0 UncorrectedTemperature
#define TEMPERATURE_1 Candle
#define TEMPERATURE_2 Tungsten40W
#define TEMPERATURE_3 Tungsten100W
#define TEMPERATURE_4 Halogen
#define TEMPERATURE_5 CarbonArc
#define TEMPERATURE_6 HighNoonSun
#define TEMPERATURE_7 DirectSunlight
#define TEMPERATURE_8 OvercastSky
#define TEMPERATURE_9 ClearBlueSky
#define TEMPERATURE_10 WarmFluorescent
#define TEMPERATURE_11 StandardFluorescent
#define TEMPERATURE_12 CoolWhiteFluorescent
#define TEMPERATURE_13 FullSpectrumFluorescent
#define TEMPERATURE_14 GrowLightFluorescent
#define TEMPERATURE_15 BlackLightFluorescent
#define TEMPERATURE_16 MercuryVapor
#define TEMPERATURE_17 SodiumVapor
#define TEMPERATURE_18 MetalHalide
#define TEMPERATURE_19 HighPressureSodium
//---------------------------------------------------------------
void loop() {
switch (temp) {
case 0:
FastLED.setTemperature( TEMPERATURE_0 ); break;
case 1:
FastLED.setTemperature( TEMPERATURE_1 ); break;
case 2:
FastLED.setTemperature( TEMPERATURE_2 ); break;
case 3:
FastLED.setTemperature( TEMPERATURE_3 ); break;
case 4:
FastLED.setTemperature( TEMPERATURE_4 ); break;
case 5:
FastLED.setTemperature( TEMPERATURE_5 ); break;
case 6:
FastLED.setTemperature( TEMPERATURE_6 ); break;
case 7:
FastLED.setTemperature( TEMPERATURE_7 ); break;
case 8:
FastLED.setTemperature( TEMPERATURE_8 ); break;
case 9:
FastLED.setTemperature( TEMPERATURE_9 ); break;
case 10:
FastLED.setTemperature( TEMPERATURE_10 ); break;
case 11:
FastLED.setTemperature( TEMPERATURE_11 ); break;
case 12:
FastLED.setTemperature( TEMPERATURE_12 ); break;
case 13:
FastLED.setTemperature( TEMPERATURE_13 ); break;
case 14:
FastLED.setTemperature( TEMPERATURE_14 ); break;
case 15:
FastLED.setTemperature( TEMPERATURE_15 ); break;
case 16:
FastLED.setTemperature( TEMPERATURE_16 ); break;
case 17:
FastLED.setTemperature( TEMPERATURE_17 ); break;
case 18:
FastLED.setTemperature( TEMPERATURE_18 ); break;
case 19:
FastLED.setTemperature( TEMPERATURE_19 ); break;
}
fill_solid(leds, NUM_LEDS, CRGB(255,255,255) ); //fill with white
if (temp==0) { leds[0]=CRGB::Red; leds[1]=CRGB::Green; leds[2]=CRGB::Blue; }
FastLED.show(); //display pixels
EVERY_N_SECONDS(DISPLAYTIME) {
FastLED.clear();
FastLED.show();
delay(BLACKOUTTIME);
temp++;
if (temp == 20) { temp = 0; } //reset
Serial.print("Current temperature: "); Serial.println(temp); //print temp # to serial monitor
}
}//end_main_loop