Skip to content

Instantly share code, notes, and snippets.

@atuline
Last active August 17, 2023 17:13
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save atuline/b279fda278417f581773 to your computer and use it in GitHub Desktop.
Save atuline/b279fda278417f581773 to your computer and use it in GitHub Desktop.
Blending using FastLED
/* 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