Colours in RGB LED not equal

I'm trying to use an three variable resistors (dimmer switchers) to modify the colours in a RGB LED, however the lights (green is incredibly dim and blue is incredibly bright). Why is this and how do I solve the problem?

**Before the red, green and blue inputs on the RGB LED I have a 220 Ohm resistor (red, red, brown, gold).

const int greenLEDPin = 9;
const int redLEDPin = 11;
const int blueLEDPin = 10;

const int redInputPin = A0;
const int greenInputPin = A1;
const int blueInputPin = A2;

int redValue = 0;
int greenValue = 0;
int blueValue = 0;

int redInputValue = 0;
int greenInputValue = 0;
int blueInputValue = 0;

void setup() {
  // put your setup code here, to run once:
  Serial.begin(9600);

  pinMode(greenLEDPin, OUTPUT);
  pinMode(redLEDPin, OUTPUT);
  pinMode(blueLEDPin, OUTPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
  redInputValue = analogRead(redInputPin);
  delay(5);
  greenInputValue = analogRead(greenInputPin);
  delay(5);
  blueInputValue = analogRead(blueInputPin);

  Serial.println("Raw Input Values:");
  Serial.print("Red - ");
  Serial.println(redInputValue);
  Serial.print("Green - ");
  Serial.println(greenInputValue);
  Serial.print("Blue - ");
  Serial.println(blueInputValue);

  redValue = 255;
  greenValue = 255;
  blueValue = 255;
  //redValue = redInputValue / 4;
  //greenValue = greenInputValue / 4;
  //blueValue = blueInputValue / 4;

  Serial.println("Mapped Input Values:");
  Serial.print("Red - ");
  Serial.println(redValue);
  Serial.print("Green - ");
  Serial.println(greenValue);
  Serial.print("Blue - ");
  Serial.println(blueValue);
  Serial.println();

  analogWrite(redLEDPin, redValue);
  analogWrite(greenLEDPin, greenValue);
  analogWrite(blueLEDPin, blueValue);

  delay(1000);
}

Thanks!

Hi, are you using an Arduino at all?

If not, the problem is that you cannot control the leds brightness accurately with variable resistors (potentiometers or "pots"). Instead you should use the Arduino to measure the pot settings and control the led brightness using PWM signals using the analogWrite() function.

If you are using Arduino as i described, well, first of all, why did you not say that?

The R, G and B leds have different forward voltages and so require different series resistors to give equal brightness and allow you to mix something close to white. Usually the series resistor for the red led should be higher than those for the green and blue. However, green and blue normally need about the same value of series resistor, but that does not seem to be the case with your led.

Post your sketch (use code tags, <>) and a schematic diagram of your circuit. Also links to the led and dimmer switches.

Paul

I'm trying to use an three variable resistors (dimmer switchers) to modify the colours in a RGB LED

Can you post a link to this and the RGB LED, because a dimmer switch is normally used with AC.

Before the red, green and blue inputs on the RGB LED I have a 220 Ohm resistor

Each LED will get a different current due to the different forward resistance and the efficiency of each colour is not the same. Normally you will have a different value of resistor for each colour. Arrange things so you get a good white when they are all on.

PaulRB:
Hi, are you using an Arduino at all?

If not, the problem is that you cannot control the leds brightness accurately with variable resistors (potentiometers or "pots"). Instead you should use the Arduino to measure the pot settings and control the led brightness using PWM signals using the analogWrite() function.

If you are using Arduino as i described, well, first of all, why did you not say that?

The R, G and B leds have different forward voltages and so require different series resistors to give equal brightness and allow you to mix something close to white. Usually the series resistor for the red led should be higher than those for the green and blue. However, green and blue normally need about the same value of series resistor, but that does not seem to be the case with your led.

Post your sketch (use code tags, <>) and a schematic diagram of your circuit. Also links to the led and dimmer switches.

Paul

I am using the arduino, I was writing the post in a rush and missed it :smiley: I have no idea how to make a schematic diagram but I have updated the post with the code I am using.

have no idea how to make a schematic diagram

Then how on earth did you make it?

LeviM:
I have no idea how to make a schematic diagram but I have updated the post with the code I am using.

Ok, i can't see any reason for your problems with your code. How about those links?

A schematic diagram shows how all your components are wired together, identifies each component and its value (like resistors).

Mike would say that you must already have a schematic, even if it is only inside your head, or you would not have been able to wire the circuit at all.

Grumpy_Mike:
Then how on earth did you make it?

I read a book, adapted an example from it to suit my goal, and put all the parts on a breadboard.

You don't have to learn some complicated app to draw a schematic. Just use pencil and paper, take a picture of it with your phone or flatbed scanner and post that.

So if you can put the parts on a bread board you can draw a schematic that shows how those components are connected together.

PaulRB:
You don't have to learn some complicated app to draw a schematic. Just use pencil and paper, take a picture of it with your phone or flatbed scanner and post that.

Grumpy_Mike:
So if you can put the parts on a bread board you can draw a schematic that shows how those components are connected together.

I don't actualy have any paper.... So I took a picture of my arduino setup and anotated it. I hope that helps. (It is saved as an attachment on my OP)

You dont have any paper???

You don't need those 1K. Just wire the centre pins of the pots to the analog inputs, and the other pot pins to 5V & ground.

Don't you have a link to any info on that rgb led? If not, you can get the info you need using a multimeter. I don't suppose you have one of those, they, like paper, are too usefull!

Those pots do not look like they are wired up correctly. You should have one end to the 5V and the other to ground, with the center going to the analogue input. There should be no fixed resistors in the pots like you seem to have.

Grumpy_Mike:
How do you wipe your bum?

I was struggling to come up with an answer to this. I either was to explain to you that toilet paper is hard to draw on or I was going to say "I dont."

Ok, ok!

No multimeter? Here's what to do. Those 3 wires connecting to the pwm pins. Tempoarily wire them direct to 5V so the led shines brightly but not particularly white. Next take a wire from an unused analog pin and connect it on the breadboard to the red pin of the led. Write a quick sketch to read the analog pin and print the value to serial monitor. Make a note of the value (dunno what on...). Then connect the wire to the green pin of the led, take reading and finally repeat for blue pin.

From the readings, you can calculate the forward voltages of the r, g & b leds inside the rgb led.

Vf = reading / 1023 * 5

What do you get?

Actually, there is a lot to be said for a bidet, or hose shower attachment.

PaulRB:
Ok, ok!

No multimeter? Here's what to do. Those 3 wires connecting to the pwm pins. Tempoarily wire them direct to 5V so the led shines brightly but not particularly white. Next take a wire from an unused analog pin and connect it on the breadboard to the red pin of the led. Write a quick sketch to read the analog pin and print the value to serial monitor. Make a note of the value (dunno what on...). Then connect the wire to the green pin of the led, take reading and finally repeat for blue pin.

From the readings, you can calculate the forward voltages of the r, g & b leds inside the rgb led.

Vf = reading / 1023 * 5

What do you get?

Would the fact that I DO have a multimetre change this?

Actually, there is a lot to be said for a bidet, or hose shower attachment.

Just don't eat and drink for 10 days, no paper will ever be needed again.

LarryD:
Just don't eat and drink for 10 days, no paper will ever be needed again.

When I came here, I had no idea this is the advice I would get

Can we not have a little fun :wink:

Would the fact that I DO have a multimetre change this?

Then measure the voltage drop anode to cathode of each, when things are connected as described.