Blynk & NeoPixel Brightness

Hi,

So I’ve set up my NodeMCU ESP8266 with blynk. I can change the led colors of my NeoPixel ring with the RGB widget.
What I’d like is to change the brightness with a slider.
In code I can set the brightness with: ring.setBrightness(value);

So, the value is what I set with the slider, but how can I do that?

Thanks!

EDIT: So, my NeoPixel only has 1 digital pin, but in the code I have a V1 (RGB) and V2 (slider), but both need to write to the same digital pin.
I tried to change the brightness with the slider, and with the following code:

BLYNK_WRITE(V2)
{
int br = param.asInt();
pixels.setBrightness(br);
}

Place a widget, hook up a virtual pin to it, set min max values 0-255

In your arduino sketch add a handler for that pin

BLYNK_WRITE(V5)
{
ring.setBrightness(param.asInt());
}

This should be your bare minimum :slight_smile:

In regards to your edit, simplest way would be to create a set button, let the other widgets save the values you want to use, and with your “set” button use those values to write to your pin

Or something like this

int R = 100;
int G =100;
int B = 100;
int brightness = 255;

BLYNK_WRITE(V1)
{
//save rgb values
// write rgb + brightness to digital pin
}

BLYNK_WRITE(V2)
{
//save brightness value
// write rgb + brightness to digital pin
}

I tried this, now the brightness changes when I change the color, thanks! When I only change the brightness it doesn’t work.
So, when making a button I thought about making a new void where it saves the values of the other widgets, and then writes to the pin.
I’m a little bit noob with coding in Arduino, do you think you could help me?

Check my previous post, follow that logic and you will update your ring on both color change and brightness change. I’m only on phone now so I can’t write that much code comfortably. Post your code and maybe I can find time today to edit it to your liking

NeoPixel is a digital led. So you are writing to a instanced object of the NeoPixel led strip, not directly to a digital pin. There for it doesn’t matter how much virtual pins you use or write to.

You can for example use V1 to. Write the rgb values, use V2 to color it red and V3 to just change the brightness.