Defining Groups of LEDs

Greetings everyone, new guy here. I am working on a project where I am using 63 through-hole neopixels. What I want to do is assign individual pixels to different groups and then use the code to turn the groups on or off. Here is a basic diagram if what I am trying to achieve :

– E –
– D –
– C –
– B –
– A –
– E –
– D –
– C –
– B –
– A –
-CORE-
– A –
– B –
– C –
– D –
– E –
– A –
– B –
– C –
– D –
– E –

Each layer of this layout has 3 LEDs, so each group A through E would have 15. The goal is to daisy chain the pixels from bottom to top to control via one data pin. Any suggestions are appreciated.

I’ve no idea what CORE and “layers” mean…

But for the world to me it seems like a very logical order. So if you want to turn on all E and E is every 5th led starting at the first then you can loop over all them by

for(byte i = 0; i < numberOfLeds; i += 5){
  turnOnLed[i];
}
[code]

septillion: I've no idea what CORE and "layers" mean...

CORE is the center layer, and the project is a vertical stack, so each layer is simply a horizontal level of lights.

septillion: So if you want to turn on all E and E is every 5th led starting at the first

Actually every "E" is three leds.

Still doesn’t make that much sens. Can you maybe make a hand drawing of it?

And if E is 3 leds in a sequence:
for(byte i = 0; i < numberOfLeds; i += 5 * 3){
turnOnLed*;*

  • turnOnLed[i+1];*
  • turnOnLed[i+2];*
    }
    * ** *

If these really are neopixels, then there are going to be 3 bytes per led: 3 * 3 * 21 = 189 bytes in the array. So mod the formula appropriately.

The goal is to have light pulsing from both the top and bottom toward the center, as per the warp core from Star Trek. I was hoping to be able to simply use #define for each group such as:

#define group_A 
#define group_B
#define group_C
#define group_D
#define group_E

Can I just list the pixels numbers for each group in the #define lines and have the code work?

Your #defines do not define anything except that they may be tested with an #ifdef. Normal usage is:
#define <actual_name>

I can’t think of anything useful you could define them to be.

If you are going to use the fastLED library, I think you may be headed down the wrong path anyway. (I don’t use that library myself). Are you planning to write your own driver for the LEDs, or use someone’s driver, or use another library?

boolrules: Are you planning to write your own driver for the LEDs, or use someone's driver, or use another library?

I was planning on using the Neopixel Library from Adafruit.

Yeah, I don't use that either (I don't believe in libraries). You should study the API (user interface) for that library and see what it requires. I'll have to bow out of this thread a let more knowledgeable people respond.

If the LEDs are in related positions then you can use an algorithm to access them, like has been discussed above. If they are arbitrary then define each group in an array or better a two dimensional array for the whole lot.

What you are trying to achieve is not clear. Not everyone watches SI-Fi onTV.

Can't agree more with Mike! You can't group them with a define, you need a function to set every led you want.

boolrules: If these really are neopixels, then there are going to be 3 bytes per led: 3 * 3 * 21 = 189 bytes in the array. So mod the formula appropriately.

Please don't, FastLed or Adafruit_NeoPixel both use led numbers, not color numbers. That each led is 3 bytes/colors is all handles by the library functions.

boolrules: If you are going to use the fastLED library, I think you may be headed down the wrong path anyway.

I don't think so, I would call that the right path. Like the FastLed library over the Adafruit_NeoPixel library. Way more options for good color representation including HSV.

boolrules: I don't believe in libraries

I would say that's quite foolish.... Why are you using Arduino then? Arduino is all based on libraries. Arduino comes packet with libraries. And not every library may be as good but I would say it's foolish to not use a library in this day and age.

I don't think so, I would call that the right path.

I meant that if he is using a library, then man-handling the color array is the wrong path. The library should provide functions for that purpose.

As far as I read he isn't. He's just handling leds aka clusters of RGB. At least, that's what I read in it.

Post #7:

I was planning on using the Neopixel Library from Adafruit.

Yes, I agree on the "using a library"-part. But that's not manhandling the color arrays in my opinion. The library is the interface between the Arduino and the leds. Which leds you want to show which color is up to the person using the library. So many wishes, so many implementations. So impossible to have a (at least not self written) library that just happens to exactly a very specific task you happen to need.