-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
54 lines (45 loc) · 924 Bytes
/
main.cpp
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
#include <Arduino.h>
#include <FastLED.h>
#define LED_TYPE WS2811
#define NUM_LEDS 50
#define COLOR_ORDER RGB
#define DATA_PIN 6
#define SMOOTHNESS 50
#define FADE_TIME 8
#define BRIGHTNESS 32
#define HUE_SHIFT 0
#define HUE_SHIFT_AMOUNT 1
CRGB leds[NUM_LEDS];
uint8_t holdMultiplier = 1;
uint16_t hue = 0;
uint8_t saturation = 0;
uint8_t counter = 0;
void twinkle() {
fadeToBlackBy(leds, NUM_LEDS, FADE_TIME);
leds[random8(50)] = CHSV(hue, saturation, 255);
FastLED.show();
}
// void hueShift() {
// twinkle();
// if (hue >= 255) {
// hue -= 255;
// } else {
// hue += HUE_SHIFT_AMOUNT;
// }
// }
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
EVERY_N_MILLISECONDS(SMOOTHNESS) {
if (counter < holdMultiplier)
{
counter++;
}
else {
twinkle();
counter = 0;
}
}
}