FastLED 3.10.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#define DATA_PIN 3
12//#define CLK_PIN 4
13#define LED_TYPE WS2811
14#define COLOR_ORDER GRB
15#if FL_PLATFORM_HAS_TINY_MEMORY
16// Keep the rainbow buffer usable on 512 B SRAM parts.
17#define NUM_LEDS 32
18#else
19#define NUM_LEDS 200
20#endif
21#define BRIGHTNESS 255
22
24
25
26void setup() {
27 delay(3000); // 3 second delay for recovery
28
29 // tell FastLED about the LED strip configuration
31 .setCorrection(TypicalLEDStrip)
32 .setDither(BRIGHTNESS < 255);
33
34 // set master brightness control
35 FastLED.setBrightness(BRIGHTNESS);
36}
37
38void pride();
39
40void loop()
41{
42 pride();
43 FastLED.show();
44}
45
46
47// This function draws rainbows with an ever-changing,
48// widely-varying set of parameters.
49void pride()
50{
51 static uint16_t sPseudotime = 0;
52 static uint16_t sLastMillis = 0;
53 static uint16_t sHue16 = 0;
54
55 uint8_t sat8 = beatsin88( 87, 220, 250);
56 uint8_t brightdepth = beatsin88( 341, 96, 224);
57 uint16_t brightnessthetainc16 = beatsin88( 203, (25 * 256), (40 * 256));
58 uint8_t msmultiplier = beatsin88(147, 23, 60);
59
60 uint16_t hue16 = sHue16;//gHue * 256;
61 uint16_t hueinc16 = beatsin88(113, 1, 3000);
62
63 uint16_t ms = millis();
64 uint16_t deltams = ms - sLastMillis ;
65 sLastMillis = ms;
66 sPseudotime += deltams * msmultiplier;
67 sHue16 += deltams * beatsin88( 400, 5,9);
68 uint16_t brightnesstheta16 = sPseudotime;
69
70 for( uint16_t i = 0 ; i < NUM_LEDS; i++) {
71 hue16 += hueinc16;
72 uint8_t hue8 = hue16 / 256;
73
74 brightnesstheta16 += brightnessthetainc16;
75 uint16_t b16 = sin16( brightnesstheta16 ) + 32768;
76
77 uint16_t bri16 = (uint32_t)((uint32_t)b16 * (uint32_t)b16) / 65536;
78 uint8_t bri8 = (uint32_t)(((uint32_t)bri16) * brightdepth) / 65536;
79 bri8 += (255 - brightdepth);
80
81 CRGB newcolor = CHSV( hue8, sat8, bri8);
82
83 uint16_t pixelnumber = i;
84 pixelnumber = (NUM_LEDS-1) - pixelnumber;
85
86 nblend( leds[pixelnumber], newcolor, 64);
87 }
88}
CRGB leds[1]
void setup()
void loop()
#define COLOR_ORDER
#define NUM_LEDS
#define BRIGHTNESS
#define DATA_PIN
Definition ClientReal.h:82
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
fl::Pride2015 pride(NUM_LEDS)
Definition Pride2015.ino:49
#define LED_TYPE
CRGB & nblend(CRGB &existing, const CRGB &overlay, fract8 amountOfOverlay) FL_NO_EXCEPT
@ TypicalLEDStrip
Typical values for SMD5050 LEDs.
Definition color.h:15
fl::hsv8 CHSV
Definition chsv.h:11
fl::CRGB CRGB
Definition crgb.h:25
LIB8STATIC u16 beatsin88(accum88 beats_per_minute_88, u16 lowest=0, u16 highest=65535, u32 timebase=0, u16 phase_offset=0) FL_NO_EXCEPT
Generates a 16-bit sine wave at a given BPM that oscillates within a given range.
Definition beat.h:63
unsigned char uint8_t
Definition stdint.h:208
fl::u32 uint32_t
Definition stdint.h:218
fl::u16 uint16_t
Definition stdint.h:213