Hi everybody!
Simple question: I guess there is a "standard setup" for the rainbow colors. I would like to know the exact RGB values of the 16 colors.
Many thanks
Matthias
RGB values of NeoPixel ring - 16
Moderators: adafruit_support_bill, adafruit
Please be positive and constructive with your questions and comments.
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: RGB values of NeoPixel ring - 16
The rainbow effect in strandtest takes the values from the color "wheel":
The wheel is defined as follows:
Code: Select all
void rainbow(uint8_t wait) {
uint16_t i, j;
for(j=0; j<256; j++) {
for(i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel((i+j) & 255));
}
strip.show();
delay(wait);
}
}
Code: Select all
// 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) {
WheelPos = 255 - WheelPos;
if(WheelPos < 85) {
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}
}
- Tissi_2
- Posts: 20
- Joined: Mon Jun 22, 2015 10:46 am
Re: RGB values of NeoPixel ring - 16
Thanks for the very quick answer! I appreciate it! Can you give me an example with a static color setup (colors not changing) for pixel 8 in the ring, please?! What would be the RGB values of that pixel?
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: RGB values of NeoPixel ring - 16
I don't know off-hand. Programmers as a rule avoid hard-coding numbers when they can let the code figure it out for them.
You could work through the math by hand, but the simplest thing to do is to just add some println statements to the code and run it.
https://www.arduino.cc/en/Serial/Println
You could work through the math by hand, but the simplest thing to do is to just add some println statements to the code and run it.
https://www.arduino.cc/en/Serial/Println
- Tissi_2
- Posts: 20
- Joined: Mon Jun 22, 2015 10:46 am
Re: RGB values of NeoPixel ring - 16
Is there any documentation how to combine several Neopixel rings and how to address the pixels on a second and third ring?
Many thanks!
Many thanks!
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: RGB values of NeoPixel ring - 16
Just connect 5v and GND together. Then connect the OUT of the first one to the IN of the next. The pixels will be addressed sequentially to the first ring. With 16 pixel rings, the second ring will be 16-31 and the third will be 32-47.
- Tissi_2
- Posts: 20
- Joined: Mon Jun 22, 2015 10:46 am
Re: RGB values of NeoPixel ring - 16
Cool, thank you so much!
- Tissi_2
- Posts: 20
- Joined: Mon Jun 22, 2015 10:46 am
Re: RGB values of NeoPixel ring - 16
Today I received my Neopixel rings - awesome hardware! Unfortunately I was not able to get the RGB values of each pixel. Here is the shortened code I am using to create a simple rainbow ring without motion:
I am not sure how to Serial.println (what) and where to place it in order to get the values.
was placed in the setup
Code: Select all
void rainbowCycle(uint8_t wait) {
uint16_t i, j;
/*for(j=0; j<256*5; j++) {*/ // 5 cycles of all colors on wheel
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
delay(wait);
}
// 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 strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
Code: Select all
Serial.begin(9600);
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: RGB values of NeoPixel ring - 16
Post your complete code and describe precisely what it is or is not doing.
- Tissi_2
- Posts: 20
- Joined: Mon Jun 22, 2015 10:46 am
Re: RGB values of NeoPixel ring - 16
Hi Bill,
I asked for the RGB values of each pixel in a 16 LED ring. Here is my code:
I used the code strip.getPixelColor(i) and Serial.println to get the values from each pixel. Here are the values:
0 = 63232
1 = 2739712
2 = 5938176
3 = 9202432
4 = 12400896
5 = 15665152
6 = 14024728
7 = 11337802
8 = 8061051
9 = 4849837
10 = 1573086
11 = 4327
12 = 14773
13 = 27532
14 = 40026
15 = 52777
What kind of values are these and how can I convert these values into RGB values? Where on the ring is the pixel(0) located?
I asked for the RGB values of each pixel in a 16 LED ring. Here is my code:
Code: Select all
#include <Adafruit_NeoPixel.h>
#include <ClickEncoder.h>
#include <TimerOne.h>
#define PIN 6
#define STRIPSIZE 16
Adafruit_NeoPixel strip = Adafruit_NeoPixel(STRIPSIZE, PIN, NEO_GRB + NEO_KHZ800);
ClickEncoder *encoder;
int16_t last, value;
int buttoncounter;
int encoderValue;
uint16_t i, j;
void timerIsr() {
encoder->service();
}
//---------------------------------------------------------------------------------------------------------------------
void setup() {
Serial.begin(9600);
strip.begin();
strip.setBrightness(30); // Lower brightness and save eyeballs!
strip.show(); // Initialize all pixels to 'off'
encoder = new ClickEncoder(A1, A0, A2, 1);
encoder->setAccelerationEnabled(false);
Timer1.initialize(1000);
Timer1.attachInterrupt(timerIsr);
last = -1;
}
//---------------------------------------------------------------------------------------------------------------------
void loop() {
value += encoder->getValue();
if (value/4 != last) {
encoderValue = value/4;
last = encoderValue;
j = encoderValue*16;
map(j, 0, 15, 0, 255);
Serial.print("Encoder Value: ");
Serial.println(j);
}
ClickEncoder::Button b = encoder->getButton();
if (b != ClickEncoder::Open) {
buttoncounter++;
Serial.print("The button was pressed ");
Serial.print(buttoncounter);
Serial.println(" time(s).");
}
if (buttoncounter == 0) {
strip.show();
}
if (buttoncounter == 1) {
rainbowCycle(25);
}
if (buttoncounter == 2) {
for(int i=0; i<strip.numPixels(); i++) {
strip.setPixelColor(i, strip.Color(0, 0, 0));
strip.show();
}
}
}
//---------------------------------------------------------------------------------------------------------------------
void rainbowCycle(uint8_t wait) {
for(i=0; i< strip.numPixels(); i++) {
strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
}
strip.show();
}
//---------------------------------------------------------------------------------------------------------------------
uint32_t Wheel(byte WheelPos) {
if(WheelPos < 85) {
return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
} else if(WheelPos < 170) {
WheelPos -= 85;
return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
} else {
WheelPos -= 170;
return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
}
}
0 = 63232
1 = 2739712
2 = 5938176
3 = 9202432
4 = 12400896
5 = 15665152
6 = 14024728
7 = 11337802
8 = 8061051
9 = 4849837
10 = 1573086
11 = 4327
12 = 14773
13 = 27532
14 = 40026
15 = 52777
What kind of values are these and how can I convert these values into RGB values? Where on the ring is the pixel(0) located?
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: RGB values of NeoPixel ring - 16
Those are the RGB values packed into a 32 bit word. To extract the Red, Green and Blue components, you need to do some bit-masking. There are some handy functions for that here: https://learn.adafruit.com/multi-taskin ... -functions
- DuaneDegn
- Posts: 141
- Joined: Thu Aug 02, 2012 1:39 pm
Re: RGB values of NeoPixel ring - 16
The RGB values can be seen easier if you output the numbers in hex. With hex each color takes up two digits and it's not hard to see the value of the component colors.
- Tissi_2
- Posts: 20
- Joined: Mon Jun 22, 2015 10:46 am
Re: RGB values of NeoPixel ring - 16
I am very sorry, but I don´t get it right with the code. I used to get the HEX values. I don´t think that these values are right. How do I have to implement this code
to Serial.println the RGBs for Pixel(1) for example?
Where is pixel(0) located on the ring?
Code: Select all
Serial.println(strip.getPixelColor(0), HEX);
Code: Select all
// Returns the Red component of a 32-bit color
uint8_t Red(uint32_t color)
{
return (color >> 16) & 0xFF;
}
// Returns the Green component of a 32-bit color
uint8_t Green(uint32_t color)
{
return (color >> 8) & 0xFF;
}
// Returns the Blue component of a 32-bit color
uint8_t Blue(uint32_t color)
{
return color & 0xFF;
}
Where is pixel(0) located on the ring?
- adafruit_support_bill
- Posts: 88096
- Joined: Sat Feb 07, 2009 10:11 am
Re: RGB values of NeoPixel ring - 16
Code: Select all
Serial.println(Red(strip.getPixelColor(1)));
Serial.println(Green(strip.getPixelColor(1)));
Serial.println(Blue(strip.getPixelColor(1)));
- Tissi_2
- Posts: 20
- Joined: Mon Jun 22, 2015 10:46 am
Re: RGB values of NeoPixel ring - 16
Thank you, Bill! If I am in NY I will get you a beer. Any specific brand?
Please be positive and constructive with your questions and comments.