FastLED 3.7.8
Loading...
Searching...
No Matches
Pride2015.ino
Go to the documentation of this file.
1
4
5#include "FastLED.h"
6
7// Pride2015
8// Animated, ever-changing rainbows.
9// by Mark Kriegsman
10
11#if FASTLED_VERSION < 3001000
12#error "Requires FastLED 3.1 or later; check github for latest code."
13#endif
14
15#define DATA_PIN 3
16//#define CLK_PIN 4
17#define LED_TYPE WS2811
18#define COLOR_ORDER GRB
19#define NUM_LEDS 200
20#define BRIGHTNESS 255
21
22CRGB leds[NUM_LEDS];
23
24
25void setup() {
26 delay(3000); // 3 second delay for recovery
27
28 // tell FastLED about the LED strip configuration
29 FastLED.addLeds<LED_TYPE,DATA_PIN,COLOR_ORDER>(leds, NUM_LEDS)
30 .setCorrection(TypicalLEDStrip)
31 .setDither(BRIGHTNESS < 255);
32
33 // set master brightness control
34 FastLED.setBrightness(BRIGHTNESS);
35}
36
37
38void loop()
39{
40 pride();
41 FastLED.show();
42}
43
44
45// This function draws rainbows with an ever-changing,
46// widely-varying set of parameters.
47void pride()
48{
49 static uint16_t sPseudotime = 0;
50 static uint16_t sLastMillis = 0;
51 static uint16_t sHue16 = 0;
52
53 uint8_t sat8 = beatsin88( 87, 220, 250);
54 uint8_t brightdepth = beatsin88( 341, 96, 224);
55 uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
56 uint8_t msmultiplier = beatsin88(147, 23, 60);
57
58 uint16_t hue16 = sHue16;//gHue * 256;
59 uint16_t hueinc16 = beatsin88(113, 1, 3000);
60
61 uint16_t ms = millis();
62 uint16_t deltams = ms - sLastMillis ;
63 sLastMillis = ms;
64 sPseudotime += deltams * msmultiplier;
65 sHue16 += deltams * beatsin88( 400, 5,9);
66 uint16_t brightnesstheta16 = sPseudotime;
67
68 for( uint16_t i = 0 ; i < NUM_LEDS; i++) {
69 hue16 += hueinc16;
70 uint8_t hue8 = hue16 / 256;
71
72 brightnesstheta16 += brightnessthetainc16;
73 uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
74
75 uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
76 uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
77 bri8 += (255 - brightdepth);
78
79 CRGB newcolor = CHSV( hue8, sat8, bri8);
80
81 uint16_t pixelnumber = i;
82 pixelnumber = (NUM_LEDS-1) - pixelnumber;
83
84 nblend( leds[pixelnumber], newcolor, 64);
85 }
86}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:21
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:715
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:59
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:47
LIB8STATIC uint16_t beatsin88(accum88 beats_per_minute_88, uint16_t lowest=0, uint16_t highest=65535, uint32_t timebase=0, uint16_t phase_offset=0)
Generates a 16-bit sine wave at a given BPM that oscillates within a given range.
Definition lib8tion.h:996
CRGB & nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay)
Destructively modifies one color, blending in a given fraction of an overlay color.
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:20
#define sin16
Platform-independent alias of the fast sin implementation.
Definition trig8.h:91
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:11
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:25