Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "FastLED.h"
- // LEDs pin
- #define DATA_PIN 3
- // LED brightness
- #define BRIGHTNESS 240
- #define NUM_LEDS 30
- // Define the array of leds
- CRGB leds[NUM_LEDS];
- void setup() {
- FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);
- FastLED.setBrightness(BRIGHTNESS);
- }
- void loop() {
- #define MIN_BRIGHTNESS 50
- #define MAX_BRIGHTNESS BRIGHTNESS
- #define HUE_COLOR 0 // red color
- #define SPEED_FADE 15 //speed of effect
- int a = millis();
- byte b = triwave8 (a/SPEED_FADE);
- byte breath = ease8InOutCubic (b);
- breath = map (breath,0,255, MIN_BRIGHTNESS, MAX_BRIGHTNESS);
- fill_solid(leds, NUM_LEDS, CHSV(HUE_COLOR, 255, breath));
- //fill_gradient(leds,NUM_LEDS,CHSV(0,255,MIN_BRIGHTNESS),CHSV(0,255,breath), CHSV(0,255,breath), CHSV(0,255,MIN_BRIGHTNESS),LONGEST_HUES); // uncomment this to smooth gradient looking effect
- adjust_gamma();
- FastLED.delay(50);
- }
- void adjust_gamma() // https://www.reddit.com/r/FastLED/comments/b2mlvf/gamma_correction/eity0u1?utm_source=share&utm_medium=web2x
- // Marc Millers simple gamma correction
- {
- for (uint16_t i = 0; i < NUM_LEDS; i++)
- {
- leds[i].r = dim8_video(leds[i].r);
- leds[i].g = dim8_video(leds[i].g);
- leds[i].b = dim8_video(leds[i].b);
- }
- }
Add Comment
Please, Sign In to add comment