calibrate RGB LEDS with PWM signal

Ive rebuild this projekt:

All works fine but i want to calibrate the RGB leds and i dont want to use restiors.

the full code is in the attachment. this is the part of the code that controls the leds.

// methods for setting colors to outputs
void setR(unsigned char value){
  analogWrite(R_PIN, value);
  R = value;
}
void setG(unsigned char value){
  analogWrite(G_PIN, value);
  G = value;
}
void setB(unsigned char value){
  analogWrite(B_PIN, value );
  B = value;
}

do you have ideas and can help me?

Bluetoothrgb.ino (9.41 KB)

i dont want to use restiors

Do you mean that you don't want to use resistors in series with the LEDs or you don't want to have to adjust their values to make the light levels the same ?

What problems are you having ?
Can you post a smaller but complete program that illustrates the problem ?

First you have to understand this:

i dont want to use restiors.

You MUST use resistors, or you will destroy the LEDs.

Resistors are required to prevent the current from exceeding the maximum specified for the LED.

yes i know i need resistors thats not my problem. the problem is that i will need different resistors for the 3 Anodes to have a nice white and the DIN IEC 63 do net have the right resistors. my idea is that i set the maximun value for red to for example to 200 so i can use for all anodes the same resitor.

BearGear:
yes i know i need resistors thats not my problem. the problem is that i will need different resistors for the 3 Anodes to have a nice white and the DIN IEC 63 do net have the right resistors. my idea is that i set the maximun value for red to for example to 200 so i can use for all anodes the same resitor.

What is your difficulty in doing that? Your code looks okay.

the code is working nice but iwant to set the max pwm signal for example for red to 200, for green to 220 and blue to 230. so i can use 3times the same resistor.

You still need to match the resistor to the led.

why nobody understand me? I know i need resistors and i use them. When you have the value 255 on the analogoutput the led will shine with full brightness but when i use for the Red green an blue led a 220ohm resistor the color red will shine brighter than green and blue because red need a voltage of 2V4v. Blue and green 3,5V. when i set the max value tho the red analogoutput to 200 instead of 255 the red led will not shine so bright.

I understand what you want to do but I fail to see what the problem is.

By all means write a small program to establish the correct value to use in analogWrite() for each colour of LED and the resistors you are using then use those values in any larger program that requires the LEDs. Make the values constants in the larger program and give them sensible names.

but the problem is im controlling these leds with a Smartphone app an i didnt have exakt values.

Write the small program to establish the values to be used at full brightness of each LED. This may well be lower than 255 for some of them.

Then when the 'phone sends "turn on red to full brightness" you can write

analogWrite(redLed, RED_FULL_BRIGHTNESS);

When the 'phone sends "turn on red to half brightness" you can write

analogWrite(redLed, RED_FULL_BRIGHTNESS / 2);

Of course, you cannot guarantee that each LED will be matched across the whole range, but that is another problem

its not so easy when you see the code im useing i found something that can maybe solve my problem but i dont know how to intigrade this to my code. can i use the constrain funktion?

can i use the constrain funktion?

You have my permission to use it.

haha:D yeah but i dont know where i have to write it down on my code

Which variable do you wish to constrain the value of and why ?