I'm a big noob when it comes to writing a sketch and have set myself a task for an upcoming 4th July project, which has come to a halt.
I'm trying to set a strip of 30 LEDs to fade from red to white to blue through FastLED on a Wemos D1 mini. I also wanted it to flash each colour after the 3 colours have faded and continuously loop these.
I have searched many different forums and managed to get the fade to go from red to blue, but can't for love nor money add the white in-between.
Can someone point me in the right direction?
#include "FastLED.h"
#define NUM_LEDS 30
#define DATA_PIN D4
#define COLOUR_ORDER GRB
CRGB leds[NUM_LEDS];
void setup() {
FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS);
}
void loop(){
//start from red
for( int colorStep=0; colorStep <= 255; colorStep++ ) {
int r = 255;
int g = 0;
int b = colorStep;
// Now loop though each of the LEDs and set each one to the current color
for(int x = 0; x < LED_COUNT; x++){
leds[x] = CRGB(r,g,b);
}
// Display the colors we just set on the actual LEDs
delay(10);
FastLED.show();
}
//into blue
for( int colorStep=255; colorStep >= 0; colorStep-- ) {
int r = colorStep;
int g = 0;
int b = 255;
// Now loop though each of the LEDs and set each one to the current color
for(int x = 0; x < LED_COUNT; x++){
leds[x] = CRGB(r,g,b);
}
// Display the colors we just set on the actual LEDs
delay(10);
FastLED.show();
}
}