FastLED 3.9.15
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
12#define DATA_PIN 3
13//#define CLK_PIN 4
14#define LED_TYPE WS2811
15#define COLOR_ORDER GRB
16#define NUM_LEDS 200
17#define BRIGHTNESS 255
18
20
21
22void setup() {
23 delay(3000); // 3 second delay for recovery
24
25 // tell FastLED about the LED strip configuration
27 .setCorrection(TypicalLEDStrip)
28 .setDither(BRIGHTNESS < 255);
29
30 // set master brightness control
31 FastLED.setBrightness(BRIGHTNESS);
32}
33
34
35void loop()
36{
37 pride();
38 FastLED.show();
39}
40
41
42// This function draws rainbows with an ever-changing,
43// widely-varying set of parameters.
44void pride()
45{
46 static uint16_t sPseudotime = 0;
47 static uint16_t sLastMillis = 0;
48 static uint16_t sHue16 = 0;
49
50 uint8_t sat8 = beatsin88( 87, 220, 250);
51 uint8_t brightdepth = beatsin88( 341, 96, 224);
52 uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
53 uint8_t msmultiplier = beatsin88(147, 23, 60);
54
55 uint16_t hue16 = sHue16;//gHue * 256;
56 uint16_t hueinc16 = beatsin88(113, 1, 3000);
57
58 uint16_t ms = millis();
59 uint16_t deltams = ms - sLastMillis ;
60 sLastMillis = ms;
61 sPseudotime += deltams * msmultiplier;
62 sHue16 += deltams * beatsin88( 400, 5,9);
63 uint16_t brightnesstheta16 = sPseudotime;
64
65 for( uint16_t i = 0 ; i < NUM_LEDS; i++) {
66 hue16 += hueinc16;
67 uint8_t hue8 = hue16 / 256;
68
69 brightnesstheta16 += brightnessthetainc16;
70 uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
71
72 uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
73 uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
74 bri8 += (255 - brightdepth);
75
76 CRGB newcolor = CHSV( hue8, sat8, bri8);
77
78 uint16_t pixelnumber = i;
79 pixelnumber = (NUM_LEDS-1) - pixelnumber;
80
81 nblend( leds[pixelnumber], newcolor, 64);
82 }
83}
CRGB leds[NUM_LEDS]
Definition Apa102.ino:11
#define NUM_LEDS
Definition Apa102.ino:6
#define BRIGHTNESS
Definition Blur.ino:8
#define COLOR_ORDER
#define LED_TYPE
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:62
central include file for FastLED, defines the CFastLED class/object
void setup()
Definition Pride2015.ino:22
void pride()
Definition Pride2015.ino:44
void loop()
Definition Pride2015.ino:35
CRGB & nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay)
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:921
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:19
#define sin16
Platform-independent alias of the fast sin implementation.
Definition trig8.h:103
Representation of an HSV pixel (hue, saturation, value (aka brightness)).
Definition chsv.h:16
Representation of an RGB pixel (Red, Green, Blue)
Definition crgb.h:55