Random RGB Values Give Pastel Colors

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?

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

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

rickso234:
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.

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.

Grumpy_Mike:

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.

Picking one to be 255 would not help.

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

Mike is correct, it does help :wink:

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.

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

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

fungus:

Grumpy_Mike:
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%).

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.

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.

afremont:
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.

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

And that's the 'S' part.

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!