-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
01E-TEST-ONE-Nixie-Clock---RGB-LED-Color.ino
256 lines (211 loc) · 7.61 KB
/
01E-TEST-ONE-Nixie-Clock---RGB-LED-Color.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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
// ONE Nixie Clock by Marcin Saj https://nixietester.com
// https://github.com/marcinsaj/ONE-Nixie-Clock
//
// LED backlight RGB test example
// Hardware:
// ONE Nixie Clock Arduino Shield - https://nixietester.com/project/one-nixie-clock
// Arduino Nano Every - https://store.arduino.cc/arduino-nano-every
//
// NOTE: For Arduino Nano Every use 5V power settings on the clock motherboard (VCC jumper)
//
// Nixie Tube Socket - https://bit.ly/nixie-socket & https://bit.ly/NixieSocket-Project
// Nixie Power Supply module and RTC DS3231 module
// Nixie Clock require 12V, 1.5A power supply
// Schematic ONE Nixie Clock - http://bit.ly/ONE-Nixie-Clock-Schematic
// Schematic Nixie Power Supply Module - http://bit.ly/ONE-Nixie-Clock-NPS-Module
// DS3231 RTC datasheet: https://datasheets.maximintegrated.com/en/ds/DS3231.pdf
#include <Adafruit_NeoPixel.h>
// https://github.com/adafruit/Adafruit_NeoPixel
// https://learn.adafruit.com/adafruit-neopixel-uberguide/arduino-library-use
// Which pin on the Arduino is connected to the NeoPixels?
#define LED_PIN A3
// How many NeoPixels are attached to the Arduino?
#define LED_COUNT 4
// Declare our NeoPixel led object:
Adafruit_NeoPixel led(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
// Argument 1 = Number of pixels
// Argument 2 = Arduino pin number
// Argument 3 = Pixel type flags:
// NEO_KHZ800 800 KHz bitstream for WS2812 LEDs
// NEO_GRB Pixels are wired for GRB bitstream
uint32_t red_color = led.Color(255, 0, 0);
uint32_t green_color = led.Color(0, 255, 0);
uint32_t blue_color = led.Color(0, 0, 255);
uint32_t white_color = led.Color(255, 255, 255);
uint32_t magenta_color = led.Color(255, 0, 255);
uint32_t led_array_color[5] =
{
led.Color(255, 0, 0), // Red color
led.Color(0, 255, 0), // Green color
led.Color(0, 0, 255), // Blue color
led.Color(255, 255, 255), // White color
led.Color(255, 0, 255) // Magenta color
};
void setup()
{
led.begin(); // Initialize NeoPixel led object
led.show(); // Turn OFF all pixels ASAP
led.setBrightness(255); // Set brightness 0-255
}
void loop()
{
PixelColor(); // Set LEDs RGB colors
PixelColorArray(); // Set LEDs RGB colors using color array
FillColor(); // Fill all LEDs with a color
FillColorArray(); // Fill all LEDs with a color using color array
FadeColor(); // Fade in/out LEDs
FadeColorArray(); // Fade in/out LEDs using color array
CrossfadeColor(); // Crossfade colors
}
void PixelColor()
{
led.setBrightness(255); // Set brightness
led.setPixelColor(0, red_color); // Set color red for LED 0
led.show(); // Update LEDs
delay(500);
led.setPixelColor(1, green_color); // Set color green for LED 1
led.show(); // Update LEDs
delay(500);
led.setPixelColor(2, blue_color); // Set color blue for LED 2
led.show(); // Update LEDs
delay(500);
led.setPixelColor(3, white_color); // Set color white for LED 3
led.show(); // Update LEDs
delay(500);
led.clear(); // Turn off LEDs
led.show(); // Update LEDs
delay(1000);
}
void PixelColorArray()
{
led.setBrightness(255); // Set brightness
for(int i = 0; i < 4; i ++)
{
led.setPixelColor(i, led_array_color[i]); // Set LEDs colors
led.show(); // Update LEDs
delay(500);
}
led.clear(); // Turn off LEDs
led.show(); // Update LEDs
delay(1000);
}
void FillColor()
{
led.setBrightness(255); // Set brightness
// led.fill(red_color);
led.fill(led.Color(255, 0, 0)); // Fill all LEDs with a color red
led.show(); // Update LEDs
delay(1000);
// led.fill(green_color);
led.fill(led.Color(0, 255, 0)); // Fill all LEDs with a color green
led.show(); // Update LEDs
delay(1000);
// led.fill(blue_color);
led.fill(led.Color(0, 0, 255)); // Fill all LEDs with a color blue
led.show(); // Update LEDs
delay(1000);
// led.fill(white_color);
led.fill(led.Color(255, 255, 255)); // Fill all LEDs with a color white
led.show(); // Update LEDs
delay(1000);
// led.fill(magenta_color);
led.fill(led.Color(255, 0, 255)); // Fill all LEDs with a color magenta
led.show(); // Update LEDs
delay(1000);
led.clear(); // Turn off LEDs
led.show(); // Update LEDs
delay(1000);
}
void FillColorArray()
{
led.setBrightness(255); // Set brightness
for(int i = 0; i < 5; i++)
{
led.fill(led_array_color[i]); // Fill all LEDs with a color
led.show(); // Update LEDs
delay(1000);
}
led.clear(); // Turn off LEDs
led.show(); // Update LEDs
delay(1000);
}
void FadeColor()
{
for (int i = 0; i <= 255; i ++) // Fade in to red
{
led.setBrightness(i); // Set brightness
led.fill(red_color); // Fill all LEDs with a color
delay(5);
led.show(); // Update LEDs
}
for (int i = 255; i >= 0; i--) // Fade out
{
led.setBrightness(i); // Set current brightness
led.fill(red_color); // Fill all LEDs with a color
delay(5);
led.show(); // Update LEDs
}
delay(1000);
}
void FadeColorArray()
{
for (int count = 0; count < 5; count++)
{
for (int i = 0; i <= 255; i ++)
{
led.setBrightness(i); // Set brightness
led.fill(led_array_color[count]); // Fill all LEDs with a color
delay(5);
led.show(); // Update LEDs
}
for (int i = 255; i >= 0; i--)
{
led.setBrightness(i); // Set current brightness
led.fill(led_array_color[count]); // Fill all LEDs with a color
delay(5);
led.show(); // Update LEDs
}
}
delay(1000);
}
void CrossfadeColor()
{
led.setBrightness(255); // Set brightness
for(int i = 0; i <= 255; i++) // Fade in to red
{
led.fill(led.Color(i, 0, 0));
delay(5);
led.show();
}
for(int i = 0; i <= 255; i++) // Crossfade to magenta
{
led.fill(led.Color(255, 0, i));
delay(5);
led.show();
}
for(int i = 0; i <= 255; i++) // Crossfade to blue
{
led.fill(led.Color(255 - i, 0, 255));
delay(5);
led.show();
}
for(int i = 0; i <= 255; i++) // Crossfade to green
{
led.fill(led.Color(0, i, 255 - i));
delay(5);
led.show();
}
for(int i = 0; i <= 255; i++) // Crossfade to red
{
led.fill(led.Color(i, 255 - i, 0));
delay(5);
led.show();
}
for(int i = 0; i <= 255; i++) // Fade out
{
led.fill(led.Color(255 - i, 0, 0));
delay(5);
led.show();
}
delay(1000);
}