Last active
August 17, 2023 17:13
-
-
Save atuline/b279fda278417f581773 to your computer and use it in GitHub Desktop.
Blending using FastLED
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* End to end blending | |
By: Andrew Tuline | |
Date: Oct 25, 2015 | |
*/ | |
#include "FastLED.h" | |
#define LED_PIN 12 | |
#define CK_PIN 11 | |
#define COLOR_ORDER BGR | |
#define CHIPSET APA102 | |
#define NUM_LEDS 12 | |
CRGB leds[NUM_LEDS]; | |
int max_bright = 32; | |
CRGB endclr; | |
CRGB midclr; | |
void setup() { | |
Serial.begin (57600); | |
FastLED.addLeds<CHIPSET, LED_PIN, CK_PIN, COLOR_ORDER>(leds, NUM_LEDS); | |
FastLED.setBrightness( max_bright ); | |
} | |
void loop(){ | |
uint8_t speed = beatsin8(6,0,255); | |
endclr = blend(CRGB::Aqua, CRGB::Orange, speed); | |
midclr = blend(CRGB::Orange, CRGB::Aqua, speed); | |
cycle(); | |
FastLED.show(); | |
} | |
void cycle() { | |
fill_gradient_RGB(leds, 0, endclr, NUM_LEDS/2, midclr); | |
fill_gradient_RGB(leds, NUM_LEDS/2+1, midclr, NUM_LEDS, endclr); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment