Hello there,
I was hoping that you could eventually help me. So I got this code for my adafruit dotstar led strip (containing 144 leds/m):
#include <Adafruit_DotStar.h>
#include <SPI.h>
#define NUMPIXELS 30
int head = NUMPIXELS;
int tail = 0;
Adafruit_DotStar strip = Adafruit_DotStar(NUMPIXELS, DOTSTAR_BRG);
void setup() {
strip.begin();
strip.show();
}
void loop() {
fade();
}
void fade(){
for(int i = 5; i < 256; i++){
for(int j = tail; j <= head; j++){
strip.setPixelColor(j, i, 0, 0);
}
strip.show();
delay(10);
}
for(int i = 255; i >= 5; i--){
for(int j = tail; j <= head; j++){
strip.setPixelColor(j, i, 0, 0);
}
strip.show();
delay(10);
}
delay(2000);
}
I want to combine it later with another written code. But first I need some help on changing the color of the fade.
I want to hand over the "fade()" function a color like green. And this color should now be faded. When I decide to change the color to red the red color should be faded.
Later it also shall fade with different colors like purple or yellow.
I don't know how to do this. I kinda thought about handing over values for r,g and b, but then I don't know how to tell the fade-function which color I want to use to fade right now.
Do you think you can help me?
Thank you in advance!