I'm trying to change the brightness of an LED light with RGB. I can change the brightness of simple colors like red, green, and blue. But I'm not sure how to change brightness of colors like purple, turquoise, and yellow green.
When it comes to adjusting the brightness of red, green, and blue. I have tried changing the values inside colorRGB().
With colorRGB():
int redPin = 9;
int greenPin = 10;
int bluePin = 11;
void setup(){
pinMode(redPin, OUTPUT);
delay(500);
pinMode(greenPin, OUTPUT);
delay(500);
pinMode(bluePin, OUTPUT);
delay(500);
}
void loop(){
colorRGB(255, 0, 0); //Brightness level 255
colorRGB(150, 0, 0); //Brightness level 150
colorRGB(50, 0, 0); //Brightness level 50
}
void colorRGB(int red, int green, int blue){
analogWrite(redPin, red);
analogWrite(greenPin, green);
analogWrite(bluePin, blue);
}
I have also tried using analogWrite(), however it needs the pin as one of its arguments so I'm not quite sure how to connect that with the already set up colors inside void loop(){}.