Hi All,
With the awesome assistance of the forum have written the following code for lighting effects on a puppet.
I’m using 3 single addressable LEDS to achieve this and am trying to simulate a lava / fire effect.
The only thing I would like to add now is more of a fade between the random colors instead of simply
switching from one to the next.
Any ideas how I could achieve this ? (I’ll obviously need to work on the timing once I get the fades
working?
Thank you.
#include "FastLED.h"
//#define COLOR_ORDER GRB
#define NUM_LEDS 3
#define LED_PIN 6
#define BRIGHTNESS 10
// Define the array of leds
CRGB leds[NUM_LEDS];
CRGBPalette16 gPal;
CRGB Colours[] =
{
CRGB(255,0,0), //RED
CRGB(255,80,0), // ORANGE
CRGB(255,100,0), // LIGHT ORANGE
CRGB(255,140,0), // YELLOW
CRGB(255,255,255), //WHITE
};
void setup() {
Serial.begin(115200);
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness( BRIGHTNESS );
}
void loop()
{
int i = random(sizeof(Colours)/sizeof(Colours[0]));
//middle horn
leds[1] = Colours[i];
FastLED.show();
// below for edge horns to be same
i = random(sizeof(Colours)/sizeof(Colours[0]));
leds[0] = Colours[i];
leds[2] = Colours[i];
FastLED.show();
// Sets the White to be much quicker.
if (i == 4) {
delay(1);
}
if (i != 4)
{
delay(50);
}
}