FastLED 3.7.8
Loading...
Searching...
No Matches
EspI2SDemo.ino
1
2
3#define FASTLED_RMT_BUILTIN_DRIVER 0
4#define FASTLED_EXPERIMENTAL_ESP32_RGBW_ENABLED 0
5#define FASTLED_EXPERIMENTAL_ESP32_RGBW_MODE kRGBWExactColors
6
7#include <FastLED.h>
8
9// How many leds in your strip?
10#define NUM_LEDS 10
11
12// For led chips like WS2812, which have a data line, ground, and power, you just
13// need to define DATA_PIN. For led chipsets that are SPI based (four wires - data, clock,
14// ground, and power), like the LPD8806 define both DATA_PIN and CLOCK_PIN
15// Clock pin only needed for SPI based chipsets when not using hardware SPI
16#define DATA_PIN 3
17
18// Define the array of leds
19CRGB leds[NUM_LEDS];
20
21// Time scaling factors for each component
22#define TIME_FACTOR_HUE 60
23#define TIME_FACTOR_SAT 100
24#define TIME_FACTOR_VAL 100
25
26void setup() {
27 Serial.begin(115200);
28 FastLED.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS); // GRB ordering is assumed
29 FastLED.setBrightness(128); // Set global brightness to 50%
30 delay(2000); // If something ever goes wrong this delay will allow upload.
31}
32
33void loop() {
34 uint32_t ms = millis();
35
36 for(int i = 0; i < NUM_LEDS; i++) {
37 // Use different noise functions for each LED and each color component
38 uint8_t hue = inoise16(ms * TIME_FACTOR_HUE, i * 1000, 0) >> 8;
39 uint8_t sat = inoise16(ms * TIME_FACTOR_SAT, i * 2000, 1000) >> 8;
40 uint8_t val = inoise16(ms * TIME_FACTOR_VAL, i * 3000, 2000) >> 8;
41
42 // Map the noise to full range for saturation and value
43 sat = map(sat, 0, 255, 30, 255);
44 val = map(val, 0, 255, 100, 255);
45
46 leds[i] = CHSV(hue, sat, val);
47 }
48
49 FastLED.show();
50
51 // Small delay to control the overall speed of the animation
52 //FastLED.delay(1);
53
54}
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
WS2812 controller class.
Definition FastLED.h:186
uint16_t inoise16(uint32_t x, uint32_t y, uint32_t z)
16-bit, fixed point implementation of Perlin's noise.
Definition noise.cpp:350
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