Go Down

Topic: What does a 15 bit color code look like? (Read 5164 times) previous topic - next topic

Qdeathstar

I am using LED strips (6803) and in order for them to come on, you need to specify the LED number and then the LED color.   

I got the LED to come on, but I can't figure out the colors without any consistency.  Apparently they use a 15 bit color code, but I've googled it and the results I come up with always result in a white LED.   

I've used the examples that come with the library, but they don't allow you to manually insert a color, EG solid white. They all fade around a color wheel..

I tried using Serial.write to see what it was sending to the LED, for red I got 99299 but although the colors were close, they were still a bit off. (eg, RED was more faded and orangy.

Thanks!
A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.

AWOL

#1
Aug 13, 2014, 06:23 pm Last Edit: Aug 13, 2014, 06:25 pm by AWOL Reason: 1
Usually it just means five bits (0..31) each for red, green and blue

Quote
99299

That's a seventeen bit number.

Grumpy_Mike

#2
Aug 13, 2014, 06:32 pm Last Edit: Aug 13, 2014, 11:49 pm by Grumpy_Mike Reason: 1
Each colour has a number of bits to control how bright it is. As you have three colours and 15 bits then each colour has 5 bits associated with it.
With 5 bits you can specify 32 different brightnesses. So if you just send the numbers 0 to 31 in turn you should get all the different shades of red.
Now it gets a bit complex because you don't understand about binary bits yet. But the numbers from 32 to 1023 in steps of 32 define all the shades of green. Then the numbers from 1024 to 32768 in steps of 1024 give you all the shades of blue.
You can work out a colour number from these components, Lets say you want 50% red 25% green and 10% blue, convert them first into steps of 32
Red = 16
Green = 8
Blue = 4 ( well 3.2 but we are dealing in integers)
So the 15 bit colour value is equal to:-
16 + ( 32 *  8 ) + ( 1024 * 4 )
or
colour = Red + 32 * Green + 1024 * Blue = 4368

Qdeathstar

So the result would be 5088  or 122564816?
A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.


Qdeathstar

I'm a bit thick, but that is around 26... I dont get it :(

A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.

Grumpy_Mike

Quote
So the result would be 5088  or 122564816?

Where do you get the 122564816 from?

Corrected final line it is 1024 not 1204, that is my dyslexia kicking in.

Qdeathstar

I don't know, i was looking at the code I had, and it looked like it might be adding them together as a string of numbers...
R    G      B
12 256 4816

but now that you edited in the answer, i got it figured out now.

Thanks for your help!
A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.

Qdeathstar

:smiley-roll:

Well, i thought i had it.

If i enter in all the numbers 1-31 i get all the different shades of GREEN

color = ( B * 1024) + (R * 32) + G

appears to be the formula, because when i do

color = ( 31 * 1024) + (0 * 32) + 0

I get full blue

and when i do

color = (0 * 1024) + (31 * 32) + 0

i get full red.



However, when I try to say, for instance get the led strip to put out "yellow"  I cant get the code to work, even though i've seen the strip put out the color yellow when it is running the fade program in the example.


The RGB code for a yellow is

R 251
G 232
B 75

I then turned those into percents:

R 44.9%
G 41.6%
B 13.4%

Then I multiplied each number by 31 and got:

R 15
G 13
B 4

then

color = ( B * 1024) + (R * 32) + G
color = (4 * 1024) + (15 * 32) + 13
color =  4589

but when i put that into the sketch, i get a whitish blue color.... not yellow.


If i use the original formula

color =  (B * 1024) + (G * 32) + R
color = (4 * 1024) = (13 * 32) + 15
color = 4527

it's just a little less red and a little less blue ( you gotta be staring at the LED's to tell)

A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.

Qdeathstar

Thanks for the setting me on the right track, guys.


I was able to get the colors working correctly.


I'm using a cheap led strip, so the colors arent quite right.  Blue is overly bright so you have to bring it way down to get purples and light blues....


For the yellows, the green overshadows the red so you got to turn the green down.

End result still looks good!


A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.

AWOL


I'm a bit thick, but that is around 26... I dont get it :(


It's a sanity check - a 26 bit number is clearly not a fifteen bit colour value.

Grumpy_Mike

Yes that happens with all LEDs the balance is never right. Sometimes you can compensate by having diffrent resistor values in the currents.
Best way is to have three pots and adjust them interactively. Some colours are impossible to get, like brown. You might also like to look at gamma correction that attempts to compensate for the fact that the eye's sensitivity is logarithmic and the LED's output is linear.

fungus


I'm a bit thick, but that is around 26... I dont get it :(


That's a 26 bit number, it can't possibly be a "color"

Advanced Arduino

Qdeathstar



I'm a bit thick, but that is around 26... I dont get it :(


It's a sanity check - a 26 bit number is clearly not a fifteen bit colour value.



Oh,    Thank you for the explanation.

@mike, I would have to put a pot on each LED since the strips are individually controlled? 
A creaking creeping shadow
stiff against the freezing fog
glares at a tickless watch.

Time has failed him -- all things shall pass.

Grumpy_Mike

No you don't put the pot on the LED strip. You connect it to the analogue input, one per pot. Then read the pot value and work out the colour number from the pot values.
To make the range add up divide the pot readings because they are 0 to 1023.

Code: [Select]
Red = analogRead(A0) >> 5;
Green = analogRead(A1) >> 5;
Blue = analogRead(A2) >> 5;


http://www.arduino.cc/en/Tutorial/Potentiometer

Go Up