RGB values of NeoPixel ring - 16

EL Wire/Tape/Panels, LEDs, pixels and strips, LCDs and TFTs, etc products from Adafruit

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
User avatar
Tissi_2
 
Posts: 20
Joined: Mon Jun 22, 2015 10:46 am

RGB values of NeoPixel ring - 16

Post by Tissi_2 »

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

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB values of NeoPixel ring - 16

Post by adafruit_support_bill »

The rainbow effect in strandtest takes the values from the color "wheel":

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);
  }
}
The wheel is defined as follows:

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);
  }
}

User avatar
Tissi_2
 
Posts: 20
Joined: Mon Jun 22, 2015 10:46 am

Re: RGB values of NeoPixel ring - 16

Post by Tissi_2 »

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?

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB values of NeoPixel ring - 16

Post by adafruit_support_bill »

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

User avatar
Tissi_2
 
Posts: 20
Joined: Mon Jun 22, 2015 10:46 am

Re: RGB values of NeoPixel ring - 16

Post by Tissi_2 »

Is there any documentation how to combine several Neopixel rings and how to address the pixels on a second and third ring?

Many thanks!

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB values of NeoPixel ring - 16

Post by adafruit_support_bill »

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.

Image

User avatar
Tissi_2
 
Posts: 20
Joined: Mon Jun 22, 2015 10:46 am

Re: RGB values of NeoPixel ring - 16

Post by Tissi_2 »

Cool, thank you so much!

User avatar
Tissi_2
 
Posts: 20
Joined: Mon Jun 22, 2015 10:46 am

Re: RGB values of NeoPixel ring - 16

Post by Tissi_2 »

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:

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);
  }
}
I am not sure how to Serial.println (what) and where to place it in order to get the values.

Code: Select all

Serial.begin(9600);
was placed in the setup

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB values of NeoPixel ring - 16

Post by adafruit_support_bill »

Post your complete code and describe precisely what it is or is not doing.

User avatar
Tissi_2
 
Posts: 20
Joined: Mon Jun 22, 2015 10:46 am

Re: RGB values of NeoPixel ring - 16

Post by Tissi_2 »

Hi Bill,

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);
  }
}
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?

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB values of NeoPixel ring - 16

Post by adafruit_support_bill »

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

User avatar
DuaneDegn
 
Posts: 141
Joined: Thu Aug 02, 2012 1:39 pm

Re: RGB values of NeoPixel ring - 16

Post by DuaneDegn »

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.

User avatar
Tissi_2
 
Posts: 20
Joined: Mon Jun 22, 2015 10:46 am

Re: RGB values of NeoPixel ring - 16

Post by Tissi_2 »

I am very sorry, but I don´t get it right with the code. I used

Code: Select all

Serial.println(strip.getPixelColor(0), HEX);
to get the HEX values. I don´t think that these values are right. How do I have to implement this code

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;
    }
to Serial.println the RGBs for Pixel(1) for example?

Where is pixel(0) located on the ring?

User avatar
adafruit_support_bill
 
Posts: 88096
Joined: Sat Feb 07, 2009 10:11 am

Re: RGB values of NeoPixel ring - 16

Post by adafruit_support_bill »

Code: Select all

Serial.println(Red(strip.getPixelColor(1)));
Serial.println(Green(strip.getPixelColor(1)));
Serial.println(Blue(strip.getPixelColor(1)));
Pixel 0 is near to the DIN pin. If you write a sketch to light up just pixel 0, it will become obvious.

User avatar
Tissi_2
 
Posts: 20
Joined: Mon Jun 22, 2015 10:46 am

Re: RGB values of NeoPixel ring - 16

Post by Tissi_2 »

Thank you, Bill! If I am in NY I will get you a beer. Any specific brand?

Locked
Please be positive and constructive with your questions and comments.

Return to “Glowy things (LCD, LED, TFT, EL) purchased at Adafruit”