forked from marmilicious/FastLED_examples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfill_up_strip.ino
76 lines (65 loc) · 2.74 KB
/
fill_up_strip.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
// fill_up_strip
// Moving pixels "fill" up strip, then clear and start again.
// The "filling" effect can be visually adjusted and slowed down near end.
// Has not been tested with a large number of pixels.
//
// Marc Miller, Oct 2015
//---------------------------------------------------------------
#include "FastLED.h"
#define LED_TYPE LPD8806
#define DATA_PIN 11
#define CLOCK_PIN 13
#define NUM_LEDS 32
#define COLOR_ORDER GRB
#define MASTER_BRIGHTNESS 255
CRGB leds[NUM_LEDS];
float delta;
uint8_t count = 0;
uint8_t hue = random8(); // Pick a random color.
uint8_t sat = random8(160,255); // Pick a random saturation in range.
// Mess with these values for fill speed and slowing effect.
uint8_t fill_delay = 20; // Increase to slow fill rate.
float delay_base = 1.17; // Used to add a delay as strip fills up.
float delay_multiplier = 2.15; // Used to add a delay as strip fills up.
/* Set delays to 1.0 if you don't want any slowing. These numbers need to
be tuned visually based on your preference and also based on the number
of pixels in your strip.
These values looked good to me with a 32 pixel strip. Small changes can
make a large difference so try small increments.
*/
//---------------------------------------------------------------
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, CLOCK_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(MASTER_BRIGHTNESS);
Serial.begin(115200); // Allows serial monitor output (check baud rate)
}
//---------------------------------------------------------------
void loop() {
// Draw the moving pixels.
for (int i=0; i < (NUM_LEDS - count); i++){
leds[i] = CHSV(hue,sat,255);
FastLED.show();
delay(fill_delay); // Slow things down just a bit.
leds[i] = CRGB::Black;
}
// Add the new filled pixels.
leds[NUM_LEDS - 1 - count] = CHSV(hue,sat,255);
FastLED.show();
count++;
// Delay the filling effect to slow near end.
delta = (pow(delay_base, count) * delay_multiplier); // Delta increases as strip fills up.
delay(delta); // Delay can increase as strip fills up.
// Uncomment to help visualize the increasing delay.
//Serial.print(" count:"); Serial.print(count); Serial.print(" delta: "); Serial.println(delta);
// Clear the strip when full.
if (count == NUM_LEDS){
Serial.println(" -------- Reset! --------");
delay(1400); // Hold filled strip for a moment.
FastLED.clear(); // Blank out the strip data.
FastLED.show();
count = 0; // Reset count.
hue = random8(); // Pick a new random fill color.
sat = random8(160,255); // Pick a random saturation in range.
delay(700); // Breif pause before filling again.
}
} //end main loop