for an art-project I'm using 16 ws2812b RGB-LEDs to light up some of the feathers of a bird.
since the 8 feathers have different sizes, I'm using 1, 2 or 3 LEDs per feather.
I don't have all the parts yet so I started with the code but I can't test it. And since I absolutely s**k at coding... I can use a pair of more talented eyes to look at it?
the idea is that this code will light up 8 sections of my "LED-strip" in 5 colors. and that those colors will rotate every 12 seconds.
Question 1 do you think this will work?
Question 2, it would be nice to add some kind of fading from one color to the next, But i can't really find any examples online that work with sections of a led strip... if someone could put me in the right direction, I would be grateful.
the full code:
#include "FastLED.h"
#define DATA_PIN 3 // Data-pin
#define LED_TYPE WS2812B // Type LED
#define COLOR_ORDER GRB //
#define NUM_LEDS 16 //
CRGBArray<NUM_LEDS> leds;
CRGBSet partA(leds(0,1));
CRGBSet partC(leds(3,4));
CRGBSet partE (leds(6,8));
CRGBSet partF(leds(9,10));
CRGBSet partG (leds(11,13));
CRGBSet partH(leds(14,15));
CHSV colorGreen(96,167,114);
CHSV colorLilac(193,114,178);
CHSV colorOrange(220,127,95);
CHSV colorRed(193,230,128);
CHSV colorYellow(255,230,128);
void setup() {
// put your setup code here, to run once:
delay [3000]; //
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop() {
// put your main code here, to run repeatedly:
partA = colorOrange;
leds[2] = colorLilac;
partC = colorGreen;
leds[5] = colorOrange;
partE = colorRed;
partF = colorYellow;
partG = colorGreen;
partH = colorLilac;
FastLED.show();
EVERY_N_SECONDS(12){
CHSV temp = colorGreen;
colorGreen = colorLilac;
colorLilac = colorOrange;
colorOrange = colorRed;
colorRed = colorYellow;
colorYellow = temp;
}
}
Yes, there is nothing to stop you doing this except your skill level.
Question 2, it would be nice to add some kind of fading from one color to the next,
Yes that can be done as well. Is the Arduino doing anything else as well as showing this sequence?
Just define one strip not the little sections you are trying to do. Then your code simply does things to various LED number ranges on that strip. You are over thinking it in that code.
I would go about it differently....i would in the setup set each strip at the desired start color in RGB format.
After the desired break, let arduino calculate the next target value. You can either set random colors, let them switch in sequence, or switch in random between predefined values.
For a fade, you can start with about 30 fade steps au intervals around 50ms and finetune from there.
Calculate the difference between old and new RGB values, divide by amount of steps, and every xy milliseconds increment/decrement until target color is reached....then start timing for new color change.
You mean because Mike didn't instantly provide you with some perfectly polished code tailored to your exact requirements? Look, Mike has a Karma score which tells you that over 2,300 people have thanked him for his help.
The answers you have so far are, in their level of detail, proportionate to the level of detail in your questions. Ask more detailed questions, you will receive more detailed answers. Share some specific, numeric detail of the requirements. Share any code you have tried already. Also Mike asked a question. He did not ask out of idle curiosity
PaulRB:
You mean because Mike didn't instantly provide you with some perfectly polished code tailored to your exact requirements? Look, Mike has a Karma score which tells you that over 2,300 people have thanked him for his help.
The answers you have so far are, in their level of detail, proportionate to the level of detail in your questions. Ask more detailed questions, you will receive more detailed answers. Share some specific, numeric detail of the requirements. Share any code you have tried already. Also Mike asked a question. He did not ask out of idle curiosity
no I don't mean that. I also said thank you, twice. so I don't really see your point. But thank you for sharing it with me.
Miniflyer:
Hi.
I would go about it differently....i would in the setup set each strip at the desired start color in RGB format.
After the desired break, let arduino calculate the next target value. You can either set random colors, let them switch in sequence, or switch in random between predefined values.
For a fade, you can start with about 30 fade steps au intervals around 50ms and finetune from there.
Calculate the difference between old and new RGB values, divide by amount of steps, and every xy milliseconds increment/decrement until target color is reached....then start timing for new color change.
Hope this helps you getting started
yes, that does help. thank you, I'll try to write something in that direction.
That last parameter, "7", is the delta between hues, from 0 to 255. If you look at the hue chart here, you will see what color the hue value represents.
In my experiments, a delta of 0 means the colors never change. A delta of 31 means that the colors between LEDS changes by significant steps. In my test, every seven LEDS in a string (I am using WS2811 strings) start as red, orange, yellow, green, aqua, blue, and purple. By incrementing gHue every few milliseconds, the starting color shifts up the chart. For example, each time I increment the starting hue by 31, the first LED of each group is in sequence, orange, yellow, green, etc. If I increment gHue by 1, then it takes a long time for the eye to detect a change in the color.
So, experiment with the gHue and delta values to get the effect you are looking for.