Problems with the red color on a RGB LED

Hi everyone

I'm trying to control the color of an common anode RGB LED, powering it using the 5v from the board and a 200ohm. using 3 potentiometers and PWM i control the each color, I have a problem as color red reaches full brightness it overpowers the other 2 colors and all you can see is a red LED.

This is the code.

#define LED_rojo    9                     //Red LED
#define LED_verde   10                    //Green LED
#define LED_azul    11                    //Blue LED
#define Pot_rojo    A0                    //Red Potentiometer
#define Pot_verde   A1                    //Green Potentiometer
#define Pot_azul    A2                    //Blue Potentiometer

int INT_verde=0,INT_rojo=0,INT_azul=0;    //color brightness (0-255)

void setup() 
  {
  pinMode(LED_rojo,OUTPUT);
  pinMode(LED_verde,OUTPUT);
  pinMode(LED_azul,OUTPUT);
  Serial.begin(9600);
  }

void lectura()                              //read and convert to a value of 0-255
  {
  int lectura=0;
  lectura=analogRead(Pot_rojo);
  INT_rojo=255-((lectura*(5.0/1023.0))*255)/5;
  lectura=0;
  lectura=analogRead(Pot_verde);
  INT_verde=255-((lectura*(5.0/1023.0))*255)/5;
  lectura=0;
  lectura=analogRead(Pot_azul);
  INT_azul=255-((lectura*(5.0/1023.0))*255)/5;
  lectura=0;
  if(INT_rojo<=255 && INT_rojo>=250){INT_rojo=255;}
  if(INT_verde<=255 && INT_verde>=250){INT_verde=255;}
  if(INT_azul<=255 && INT_azul>=250){INT_azul=255;}
  if(INT_rojo<=5 && INT_rojo>=0){INT_rojo=0;}
  if(INT_verde<=5 && INT_verde>=0){INT_verde=0;}
  if(INT_azul<=5 && INT_azul>=0){INT_azul=0;}  
  }

void loop() {
  lectura();
  analogWrite(LED_rojo,INT_rojo);           //write the red LED
  analogWrite(LED_verde,INT_verde);         //write the green LED
  analogWrite(LED_azul,INT_azul);           //write the blue LED
  Serial.print("Rojo: ");                   
  Serial.print(INT_rojo);                   
  Serial.print(" Verde: ");                 
  Serial.print(INT_verde);                 
  Serial.print(" Azul: ");                 
  Serial.println(INT_azul);                 
}

You need 3 (three) resistors as D10 below.

Tune the values of these resistors for your needs.

The resistor for the red may need to be a higher value.

The chemistry/physics of the different colors makes the LED voltage different for each color so with the same voltage applied across the LED & resistor, the currents will be different.

But... I don't know if matching the currents will make the perceived brightness... That might be in the datasheet or you might just have to experiment.

The datasheet WILL give the voltage for each color so you can calculate the resistors to match the current.

And if you're only one resistor on the common anode things will REALLY get fouled-up.

OP said, "a 200 ohm". Red LEDs often have the lowest junction voltage so it makes perfect sense.

Try something in the 500 ohm range for the red led, that will reduce the current and its brightness.

Three main factors control the perceived brightness of an LED:
The current
the efficiency of the LED and
the sensitivity of your eyes. Which is different at different colours.

Because you havent given a link to the common anode RGB LED you are using I can only generalise:
RED leds generally are very efficient and have a working voltage of around 2.0V.
So if youre driving them from a UNO or other 5V board you have
3V across the 200 ohm resisitor - giving 15mA
BLUE leds generally are very efficient and have a working voltage of around 3.0V
So if youre driving them from a UNO or other 5V board you have
2V across the 200 ohm resisitor - giving 10mA
GREEN leds come in different types; some are OK, some VERY inefficient. also the forward voltage may be 2V to 4V.
Then your eyes are more sensitive to green than to red or blue