Hi,
I tried to write a code to fade between two colors but it’s not smooth
And too slow to reach the final color
Also how can I fade the colors to off?
And when I use rainbow I can’t turn it off
Another problem is that every time I push the button it run twice,once for press and once for release.
How can I run it once without switch button?
BLYNK_WRITE(V2)
{
rainbow();
}
BLYNK_WRITE(V3)
{
setAll(125,47,0); //candle
}
BLYNK_WRITE(V4)
{
int Bright = param.asInt();
pixels.setBrightness(Bright);
pixels.show();
}
BLYNK_WRITE(V6)
{
setAll(0,0,0);
}
void loop()
{
Blynk.run();
}
void setAll(byte r, byte g, byte b) {
uint32_t j;
for (j = 0; j < 255; j++) {
for(int i = 0; i < NUMPIXELS; i++ ) {
pixels.setPixelColor(i, pixels.Color(r, g, b));
}
pixels.setBrightness(j);
pixels.show();
delay(1);
}
//delay(50);
}
void rainbow() {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<NUMPIXELS; i++) {
pixels.setPixelColor(i, Wheel((i+j) & 255));
}
pixels.show();
delay(5);
}
}
uint32_t Wheel(byte WheelPos) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return pixels.Color(255 - WheelPos * 3, 0, WheelPos * 3);
}
if(WheelPos < 170) {
WheelPos -= 85;
return pixels.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
WheelPos -= 170;
return pixels.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}