So, I am new to Arduino and am only using it for an external project. i have an UNO R3 and WS2811 led strip. I need to be able to fade between custom colours (000,000,000 format) with different brightness values for the colours. I have found templates online for fading between colours such as this - but I dont know how to insert my own colours instead of RGB.
void loop(){
// Let’s take 256 steps to get from blue to red
// (the most possible with an LED with 8 bit RGB values)
for( int colorStep=0; colorStep<255; colorStep++ ) {
int g = colorStep; // Redness starts at zero and goes up to full
int b = 255-colorStep; // Blue starts at full and goes down to zero
int r = 0; // No green needed to go from blue to red
// Now loop though each of the LEDs and set each one to the current color
for(int x = 0; x < NUM_LEDS; x++){
leds = CRGB(r,g,b);
}
// Display the colors we just set on the actual LEDs
FastLED.show();
delay(10);
}
Additionally, since we see colours logarithmically, the fade I noticed bounces off each colour zigzagging instead of smoothly transitioning. I was thinking a Sine wave would be a good template for this but logarithmic fading would be better. This thread seemed very important however I couldn’t work out how to implement the snips of code that were suggested.
A ‘fade table’ was suggested to change the values of the fade to a logarithmic sequence, however I couldn’t find more mention of a ‘fade table’ online. I understand this to mean dividing the transition time equally between 8 divisions of the colour arc.
0: 0
1: 1
2: 3
3: 7
4: 15
5: 31
6: 63
7: 127
8: 255
Being able to customise the code as much as possible is important so I can tweak delays, colour values and fade times so I’m imagining simple composite code is the best way to make it so I can just change some integers to fine tune it rather than the whole code- so I’m not really after code that summarizes the process if that makes any sense. I feel on the cusp of it but was wondering if anyone knows how to piece together these snips of info into the project I’m suggesting. Its a shot in the dark but maybe someone would like to take on this challenge! As I’ve been searching for a long time and my deadline is running out, any help would be hugely appreciated!!!
Many thanks
Ras