Go Down

Topic: Defining Groups of LEDs (Read 568 times) previous topic - next topic

agdiv

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.

septillion

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
Code: [Select]
for(byte i = 0; i < numberOfLeds; i += 5){
  turnOnLed[i];
}
[code]
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

agdiv

#2
Mar 20, 2017, 06:48 pm Last Edit: Mar 20, 2017, 08:44 pm by agdiv
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.

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.

septillion

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];
}
Code: [Select]
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

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.

agdiv

#5
Mar 20, 2017, 09:12 pm Last Edit: Mar 20, 2017, 09:17 pm by agdiv
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:

Code: [Select]

#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?


boolrules

Your #defines do not define anything except that they may be tested with an #ifdef. Normal usage is:
#define   <alias>  <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?

agdiv

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.

boolrules

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.

Grumpy_Mike

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.

septillion

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

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.

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.

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.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

boolrules

#11
Mar 21, 2017, 02:52 pm Last Edit: Mar 21, 2017, 02:53 pm by boolrules
Quote
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. 

septillion

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.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

boolrules

Post #7:
Quote
I was planning on using the Neopixel Library from Adafruit.

septillion

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.
Use fricking code tags!!!!
I want x => I would like x, I need help => I would like help, Need fast => Go and pay someone to do the job...

NEW Library to make fading leds a piece of cake
https://github.com/septillion-git/FadeLed

Go Up