Please edit your post to add triple backticks at the beginning and end of your code so that it displays correctly.
Triple backticks look like this:
```
Most people probably don’t have the same hardware as you, and even if they do they probably can’t be bothered to find it, upload your code, set-up the app and try to figure-out what:
actually means in practice.
Even if they did all of that, they don’t understand what you mean by:
so, it’s very difficult for us to help you.
If you’re using the Wemos WS2812B RGB Shield then the single neopixel is attached to pin D2 (the little asterisk next to D2 is the clue).
That means that telling the library that you have 7 neopixels attached to pin D4 probably isn’t a great start:
Pete, I made some changes to the code but it still doesn't work.
What I want to do is that when I choose a color that the leds start off setBrightness = 0 and go up to 100. But loop (this is the effect “fade” for me".
#include <Adafruit_NeoPixel.h>
#include <SPI.h>
#include <BlynkSimpleEsp8266.h>
#include <ESP8266WiFi.h>
#define PIN D4
#define NUMPIXELS 7
#define BLYNK_PRINT Serial
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);
char auth[] = "YizbKmQ6_AIV3pnyh4ZA-Euu7JKxTv7L";
const char* ssid = "----";
const char* pass = "----";
BLYNK_CONNECTED() {
// Request the latest state from the server
Blynk.syncAll();
}
void setup()
{
Serial.begin(9600);
Blynk.begin(auth, ssid, pass);
pixels.begin();
}
BLYNK_WRITE(V1)
{
int R = param[0].asInt();
int G = param[1].asInt();
int B = param[2].asInt();
Serial.println(R);
Serial.println(G);
Serial.println(B);
int fadeVal=0;
for(int i=0;i<NUMPIXELS;i++){
pixels.setPixelColor(i, pixels.Color(R,G,B));
pixels.show();
}
for (int fadeVal=0; fadeVal>100; fadeVal++){
pixels.setBrightness(fadeVal);
Serial.println("fadeVal=");
Serial.println(fadeVal);
delay(50);
}
for(int fadeVal=100; fadeVal>=0; fadeVal--) { // Ramp down from 255 to 0
pixels.setBrightness(fadeVal);
Serial.println("fadeVal=");
Serial.println(fadeVal);
delay(50);
}
}
void loop()
{
Blynk.run();
}
Are you trying to make (for example) red slowly fade to a new color (say green) by transitioning thru yellow? Or are you trying to make red slowly fade (change brightness) to black/off and then back to the new color you selected? Either way I would recommend you work in the HSV (hue, saturation, brightness) world instead of RBG world. There are functions for working in the HSV world. You will have to make the hue (or brightness) changes in a “loop” in your code.
The tricky part is to do this while not waiting too long between calls to Blynk. If your loop takes too long you may need to make Blynk calls within the loop. Or another (better) option is to have a very short timer that does the hue or brightness incremental changes and then goes back to the main loop so as to not block calls to Blynk.
The alternative is to use a library that uses an RGBB (Red, Green, Blue, Brightness) function that automatically handles the fade for you.
Either way, It’s not really a Blynk related issue, and not worth forum members spending time on something that isn’t exactly a critical piece of functionality (uin my opinion).
FYI: You need a pixels.show() after each time you change brightness. Probably why your not seeing anything happen. Your code should only “pulse” once and only upon changing colors.
Also instead of zebra you could use a single slider for hue. It’s not as user friendly for picking colors on the zebra but then you could use the Hue, Saturation, Value functions and not have to deal with the R.G,B math when changing brightness.