Neopixel brightness

Hi, I need some help. I’m about to go crazy over this

I’m using this basic sketch

 #define BLYNK_PRINT Serial
 #include <Adafruit_NeoPixel.h>
 #include <SPI.h>
 #include <BlynkSimpleEsp8266.h>
 #include <ESP8266WiFi.h>

 #define PIN            D2 // GPIO pin
 #define NUMPIXELS      12 // Number of pixels in strip
 #define BLYNK_PRINT Serial    // Comment this out to disable prints and save space
  Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800);

char auth[] = "mytoken";  // You should get Auth Token in the Blynk App.

void setup()
{
   Serial.begin(9600);
  Blynk.begin(auth, "Smartnet", "Pass");
pixels.begin();
}

BLYNK_WRITE(V2) // Widget WRITEs to Virtual Pin V2
{

int R = param[0].asInt();
int G = param[1].asInt();
int B = param[2].asInt();
  Serial.println(R);
  Serial.println(G);
  Serial.println(B);

for(int i=0;i<NUMPIXELS;i++){
    pixels.setPixelColor(i, pixels.Color(R,G,B)); // Moderately bright green color.
    pixels.show(); // This sends the updated pixel color to the hardware.
}
}
void loop()
{
  Blynk.run();
}

That works fine I can control my neo pixels ring wich I have connected to my NodeMcu. On pin D2. Virtual pin 2
How do I add brightness control to all of this? so it will work with a slider from inside the blynk app?

Please edit your post to show the full unmodified code (no ** ) but place it within two groups of three backticks at the top and bottom like this so it will show properly. Thanks.

Done :smiley:

It appears you are using the zeRGBa widget, so “brightness” is already incorporated by the varying values 0-255 of each of the three primary colours. On the widget, up/down controls the intensity, while left/right is the colour range.

I don’t have any NeoPixels to test with, but based on your code I guess they should function the same way as a basic RGB LED, just with one command instead of three distinct pin controls.

EDIT - After a bit of quick reading here: Arduino Library Use | Adafruit NeoPixel Überguide | Adafruit Learning System it looks like you are setting the NeoPixels with the 32bit settings? Just a guess, but try this instead:

pixels.setPixelColor(i, pixels(R,G,B));

I also found reference to overall brightness control with this command:

strip.setBrightness(64);

In which case you could tie it into a single slider like such:

BLYNK_WRITE(Vx) // Brightness slider
{
  int Bright = param.asInt();
  strip.setBrightness(Bright);
} // END Blynk Function