I bought a lot of neopixels to use as my christmas lights, and I use a number of random functions to generate colors to do animations etc. The problem I am having is that a lot of the random colors are pastels (close to white) and just do not look very vivid. I have been looking at ways to get more saturated color, but I don't understand the color space very well yet.
The best I have come up with so far is randomly choosing to set one of the values (R,G,B) to zero to make the colors stronger, but I think I am probably missing colors by doing this.
Any thoughts or suggestions would be appreciated.
How to get vivid / saturated colors on NeoPixel
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- billmorton
- Posts: 19
- Joined: Tue Dec 22, 2009 9:56 am
- adafruit_support_bill
- Posts: 88091
- Joined: Sat Feb 07, 2009 10:11 am
Re: How to get vivid / saturated colors on NeoPixel
Actually, that is not a bad strategy. The color space looks like the diagram below. R, G and B are at the corners. Combinations of any two define the edges of the triangle. When you start introducing a third led, it start pulling you into the center part of the space which goes through the pastels and ultimately to white.The best I have come up with so far is randomly choosing to set one of the values (R,G,B) to zero to make the colors stronger
- adafruit_support_rick
- Posts: 35092
- Joined: Tue Mar 15, 2011 11:42 am
Re: How to get vivid / saturated colors on NeoPixel
Just reduce the brightness of one of the color components - you don't have to go all the way to zero. You can use all the values in between 0 and 255.
Try adding a multiplier of .75 (for integer math, multiply by three and divide by four) to one of your random numbers, and see if the pastels become more saturated.
Try adding a multiplier of .75 (for integer math, multiply by three and divide by four) to one of your random numbers, and see if the pastels become more saturated.
- billmorton
- Posts: 19
- Joined: Tue Dec 22, 2009 9:56 am
Re: How to get vivid / saturated colors on NeoPixel
I will give that a shot and see how it goesadafruit_support_rick wrote:Just reduce the brightness of one of the color components - you don't have to go all the way to zero. You can use all the values in between 0 and 255.
Try adding a multiplier of .75 (for integer math, multiply by three and divide by four) to one of your random numbers, and see if the pastels become more saturated.
- hiduino
- Posts: 862
- Joined: Sat Sep 01, 2012 7:05 pm
Re: How to get vivid / saturated colors on NeoPixel
The best way to get vivid colors is to use the color Wheel() routine used in the NeoPixel Strandtest example.
Here is a simple Christmas tree light program I used for my Christmas tree. Note, I am using the thin digital RGB LEDs based on the WS2801 instead of the Neopixel LEDs. Just replace the beginning portion for the NeoPixel definitions.
Here is a simple Christmas tree light program I used for my Christmas tree. Note, I am using the thin digital RGB LEDs based on the WS2801 instead of the Neopixel LEDs. Just replace the beginning portion for the NeoPixel definitions.
Code: Select all
#include "SPI.h"
#include "Adafruit_WS2801.h"
uint8_t dataPin = 2; // Yellow wire on Adafruit Pixels
uint8_t clockPin = 3; // Green wire on Adafruit Pixels
Adafruit_WS2801 strip = Adafruit_WS2801(25, dataPin, clockPin);
int randomp, randomi;
void setup() {
strip.begin();
// Initialize the lights with random colors
for (int i = 0; i < strip.numPixels(); i++) {
randomi = random(256);
strip.setPixelColor(i, Wheel( randomi ) ) ;
}
strip.show();
}
void loop() {
randomp = random(strip.numPixels());
randomi = random(256);
if (strip.getPixelColor(randomp) == 0) {
strip.setPixelColor(randomp, Wheel( randomi ));
} else {
randomp = random(strip.numPixels());
strip.setPixelColor(randomp, 0);
}
strip.show();
delay(100);
}
/* Helper functions */
// Create a 24 bit color value from R,G,B
uint32_t Color(byte r, byte g, byte b)
{
uint32_t c;
c = r;
c <<= 8;
c |= g;
c <<= 8;
c |= b;
return c;
}
//Input a value 0 to 255 to get a color value.
//The colours are a transition r - g -b - back to r
uint32_t Wheel(byte WheelPos)
{
if (WheelPos < 85) {
return Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if (WheelPos < 170) {
WheelPos -= 85;
return Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
Please be positive and constructive with your questions and comments.