Hi all, I am testing a RGB led (the included in starter kit) and I am providing each input different voltages via PWM pins.
When I give them mono color values like (255, 0, 0), (0, 255, 0) and (0, 0, 255) The led works perfectly, but if, for example, provide him white (255, 255, 255), the led is not white, it shows a "purpled white".
I googled a few and found that the reason is that each "inner LED" has it's own voltage specs.
True, the datasheet says:
Now I edited my code. Blue and green pin works with same voltage, but red brights more with less voltage. To calibrate the red I change my analogWrite to red. Let's assume that 3.3V is 255.
1.95 Volts should be 255 in red led: redValue * (1.95 / 3.3) is the new code to write to redPin.
Now white looks more white, but if I try to show other color, like brown(103, 64, 58), the result is ridiculous:
Pink

How can I represent real colors with this led?
The code:
const int redPin = 11;
const int greenPin = 9;
const int bluePin = 10;
int redValue = 0;
int greenValue = 0;
int blueValue = 0;
void setup() {
Serial.begin(9600);
pinMode(redPin, OUTPUT);
pinMode(greenPin, OUTPUT);
pinMode(bluePin, OUTPUT);
redValue = 103;
greenValue = 64;
blueValue = 58;
}
void loop() {
updateLed();
}
void updateLed(){
analogWrite(redPin, redValue * 1.95/3.3);
analogWrite(greenPin, greenValue/3.3);
analogWrite(bluePin, blueValue/3.3);
}