Led Control Help

Hi,

I’m not sure why I am having a hard time wrapping my head around this but I’m working on a project where I have an rgb led strip and I want to control the color and brightness of the strip with my arduino. I can control the color just fine but when it comes to brightness I’m not sure where to start.

Which rgb led strip? Link?

Its just your standard 5050 led strips.

" I can control the color just fine but when it comes to brightness I'm not sure where to start."
If your script is working to control the color, it should be pretty easy to control the brightness of each color with analogWrite().

Show us a copy of your code please.

int redPin = 9;
int greenPin=11;
int bluePin = 10;
int bright=.1;

void setup()
{
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
}

void loop()
{
setColor(167, 0, 255);
}

void setColor(int red, int green, int blue)
{
#ifdef COMMON_ANODE
red = (255 - red)*bright;
green = (255 - green)*bright;
blue = (255 - blue)*bright;
#endif
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);

}

The issue I am running into is overall brightness or intensity. I'm just not sure how to program that or if I need to handle that in the circuit

Try this for the loop()

void loop()
{
 setColor(167, 255, 255);
 delay(1000);
 setColor(20, 200, 25); 
 delay(1000);
 setColor(40, 50, 25); 
 delay(1000);
 setColor(9, 20, 25);
 delay(1000); 
}

BTW "int bright=.1;" will not work. int will not take decimals.

Alright, Cool. I didn't even notice I put int instead of float but is there a way to have a variable control the brightness?

" is there a way to have a variable control the brightness?"

There is a way to have a variable to control the three different colors brightness.

Try the code I suggested, and if it works sorta, we can discuss using a single variable.

Alright, Thanks but I actually found a better solution to my problem. I think I'm going to us the HSV model which allows for the control I need. Once again thanks for the help, Ill keep you guys posted on what happens.