FastLED 3.9.7
Loading...
Searching...
No Matches
Blur.ino
1// Description: This example shows how to blur a strip of LEDs. It uses the blur1d function to blur the strip and fadeToBlackBy to dim the strip. A bright pixel moves along the strip.
2// Author: Zach Vorhies
3
4#include <FastLED.h>
5
6#define NUM_LEDS 64
7#define DATA_PIN 3 // Change this to match your LED strip's data pin
8#define BRIGHTNESS 255
9
10CRGB leds[NUM_LEDS];
11uint8_t pos = 0;
12bool toggle = false;
13
14void setup() {
15 FastLED.addLeds<WS2812B, DATA_PIN, GRB>(leds, NUM_LEDS);
16 FastLED.setBrightness(BRIGHTNESS);
17}
18
19void loop() {
20 // Add a bright pixel that moves
21 leds[pos] = CHSV(pos * 2, 255, 255);
22 // Blur the entire strip
23 blur1d(leds, NUM_LEDS, 172);
24 fadeToBlackBy(leds, NUM_LEDS, 16);
25 FastLED.show();
26 // Move the position of the dot
27 if (toggle) {
28 pos = (pos + 1) % NUM_LEDS;
29 }
30 toggle = !toggle;
31 delay(20);
32}
CFastLED FastLED
Global LED strip management instance.
Definition FastLED.cpp:45
central include file for FastLED, defines the CFastLED class/object
void setBrightness(uint8_t scale)
Set the global brightness scaling.
Definition FastLED.h:723
void show(uint8_t scale)
Update all our controllers with the current led colors, using the passed in brightness.
Definition FastLED.cpp:94
static CLEDController & addLeds(CLEDController *pLed, struct CRGB *data, int nLedsOrOffset, int nLedsIfOffset=0)
Add a CLEDController instance to the world.
Definition FastLED.cpp:79
WS2812B controller class.
Definition FastLED.h:204
@ GRB
Green, Red, Blue (0102)
Definition eorder.h:17
void blur1d(CRGB *leds, uint16_t numLeds, fract8 blur_amount)
One-dimensional blur filter.
void fadeToBlackBy(CRGB *leds, uint16_t num_leds, uint8_t fadeBy)
Reduce the brightness of an array of pixels all at once.
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:54