Go Down

### Topic: Random RGB Values Give Pastel Colors (Read 2908 times)previous topic - next topic

#### rickso234

##### Mar 24, 2013, 02:30 pm
Have some RGB LEDS in a strip and looking to create some random colors for a background effect. When I calculate three random numbers say from 1 to 50 (so they're not too bright) then set the R, G, and B LEDS to those values I get different colors but they're always pastel and never vivid.

Is there a way to process the random numbers somehow to weight them toward more vivid colors, maybe pick numbers from 1 to 255 then scale them down to reduce brightness?

Would I have better luck to create an array of RGB numbers for colors that I want and just randomly step around the array?

#### johnwasser

#1
##### Mar 24, 2013, 02:40 pm
Unless one of the three colors is 0 you will not get vivid colors. Any amount of brightness shared by all three will come out as white mixed with your color.  For example 50R/50G/0B is bright yellow but 50R/50G/30B is pastel yellow.

You could pick three random values and then randomly pick one of the three to set to 0.

0R/50G/30B = Greenish Blue
50R/0G/30B = Reddish Purple
50R/50G/0B = Bright Yellow
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

#### rickso234

#2
##### Mar 24, 2013, 03:01 pm
Great idea... and I like the idea of randomly altering random numbers!

#### fungus

#3
##### Mar 24, 2013, 03:59 pm

Great idea... and I like the idea of randomly altering random numbers!

You could use HSV color model, not RGB color model. Random 'hue' will always be saturated.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#### Grumpy_Mike

#4
##### Mar 25, 2013, 12:44 am
Quote
You could pick three random values and then randomly pick one of the three to set to 0.

You can also pick one to be randomly 255 as well.
The other way is to jay use the top two bits of each component.
In truth there are not all that many vivid colours anyway.

#### johnwasser

#5
##### Mar 25, 2013, 01:29 am

Quote
You could pick three random values and then randomly pick one of the three to set to 0.

You can also pick one to be randomly 255 as well.
The other way is to jay use the top two bits of each component.
In truth there are not all that many vivid colours anyway.

Picking one to be 255 would not help.  Changing  250R/200G/200B to 255R/200G/200B would only get you a slightly more intense pale pink.  Changing to 0R/200G/200B, 250R/0G/200B or 250R/200G/0B would get Cyan, Purple, and Yellow, respectively.
Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

#### Grumpy_Mike

#6
##### Mar 25, 2013, 09:47 am
Quote
Picking one to be 255 would not help.

Yes it does, have you tried it? It allows secondary colours which can be vivid.

#### Headroom

#7
##### Mar 27, 2013, 11:53 am
Mike is correct, it does help

This trippylighting.com ( scroll down to the video) does exactly that. It randomly chooses 3 values and then clamps one of them to 255 and then fades from the last set of randomly chosen values to the new set.
http://trippylighting.com

http://ledshield.wordpress.com/

#### fungus

#8
##### Mar 27, 2013, 12:58 pm

In truth there are not all that many vivid colours anyway.

1536 of them in the HSV model with 256 values for RGB.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#### johnwasser

#9
##### Mar 27, 2013, 01:35 pm

In truth there are not all that many vivid colours anyway.

1536 of them in the HSV model with 256 values for RGB.

Or 36,001 if Hue is 0-359 degrees and Value is 0 to 100% (Saturation is 100%).

http://www.csgnetwork.com/csgcolorsel4.html

250R/200G/200B = 0°H/20%S/98%V

Inserting 255 in one position:
255R/200G/200B = 0°H/22%S/100%V
250R/255G/200B = 65°H/22%S/100%V
250R/200G/255B = 295°H/22%S/100%V
In all three cases the saturation value is only 22%, very pastel.

Inserting 0 in one position:
0R/200G/200B = 180°H/100%S/78%V
250R/0G/200B = 312°H/100%S/98%V
250R/200G/0B = 48°H/100%S/98%V
In all three cases the saturation value is 100%, quite vivid.

Send Bitcoin tips to: 1L3CTDoTgrXNA5WyF77uWqt4gUdye9mezN
Send Litecoin tips to : LVtpaq6JgJAZwvnVq3ftVeHafWkcpmuR1e

#### afremont

#10
##### Mar 27, 2013, 02:56 pm
I had the best results with nice colors by only lighting two LEDs at a time.  If you ramp the PWM up and then down by 1, while overlapping with the next color(R&G, G&B, B&R) by 180 degrees, you get a rainbow of vivid colors.  Any illumination of the third LED will just make the color lose saturation.
Experience, it's what you get when you were expecting something else.

#### fungus

#11
##### Mar 27, 2013, 04:09 pm

I had the best results with nice colors by only lighting two LEDs at a time.  If you ramp the PWM up and then down by 1, while overlapping with the next color(R&G, G&B, B&R) by 180 degrees, you get a rainbow of vivid colors.

That's the 'H' part of HSV.

Any illumination of the third LED will just make the color lose saturation.

And that's the 'S' part.
No, I don't answer questions sent in private messages (but I do accept thank-you notes...)

#### Headroom

#12
##### Mar 31, 2013, 03:28 am
I actually have to revise what I had stated earlier. Clamping one of the values to 255 is not going to work. The way the rings are generated in my lighting system is that the optics in fromt of the LED head " clamps" one of the colors to zero.
So in essence if your algorithm chooses one of the three channels to clamp to zero and then you choose values randomly for the other two channels it'll work better.

However, the approach fungus has posted, selectin HSV and conveting it to RGB - while more complicated to implement and more computationally expensive - is by far the best approach!
http://trippylighting.com

http://ledshield.wordpress.com/

Go Up

Please enter a valid email to subscribe

### Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy