I want to make a neopixel matrix but the matrix gonna be an hexagon. so it won’t be just a 8 x 8 matrix. How do i define the leds in my code?
(see the picture for an example of my problem)
This is some code i would like to change for my hexagon matrix.
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix(5, 7, 3,
NEO_MATRIX_TOP + NEO_MATRIX_LEFT +
NEO_MATRIX_ROWS + NEO_MATRIX_ZIGZAG,
NEO_RGB + NEO_KHZ800);
Here’s what that code means:
Adafruit_NeoMatrix matrix = Adafruit_NeoMatrix( = “build me a new matrix”
5 = “that is 5 pixels wide”
7 = “and 7 LED strips tall.”
3 = “I will plug my blue data wire from my LED strips into pin 3 on my arduino.”
NEO_MATRIX_TOP + NEO_MATRIX_LEFT = “The beginning of my strip, nearest the arduino, is at the top left corner of my matrix.”
NEO_MATRIX_ROWS = “I’m orienting my strips horizontally, not vertically.”
NEO_MATRIX_ZIGZAG = “I’m soldering my strips in a zigzag pattern, not a progressive pattern.”
The picture you post looks more like a beat-up Batman logo than any hexagon… Is that your final layout ??
It is not clear to me the problem you are trying to fix. I am only guessing you need to map each pixel’s linear address [From 0 to 57]
to a value more representative of the pixels actual position within your final shape !?
Please give more detail as to what animation you plan to do…Best is to provide the complete code that you have. What HW are you using ?
One thing you can do is write code that assumes you actually have a matrix, but then write your XY() function (that maps x, y coords to the index of your leds array) such that it returns a dummy value for pixels that aren’t actually there.
(I had success with this technique on my Technocolour Dreamcoat project—the “holes” in the matrix under the arms just returned dummy values. Search my posts for links to the code.)
sorry for the unclear question, my english is not that good and i am just a beginner with leds I have some neopixel ledstrips what i want to cut in pieces to make my hegaxon matrix. controled by an arduino uno.
The picture is from someone else his project, I did not allready cut my stips in pieces but the problem is the same i think.
The matrix wil be build up like this (number of leds in a row)
You are referring to the Adafruit NeoMatrix Library in your initial post. Do you plan to use that? In that case, you should direct your question to Adafruit support !?
That being said, you can of course use the FastLED library instead and benefit from all the great features this library offers.
To answer your initial question…
How do i define the leds in my code?
If you are using FastLED it would look something like this…
The more complicated part will be to create animations and control the LEDs in that hexagonal shaped array.
If you are a real beginner, I strongly recommend that you play with the strip and some basic animations on it before you start cutting it up for your hexagonal shape !
@JP_Roy Thanks, I have asked the same question in the Adafrui forum as well. I am a beginner, only tried some Fastled libaries on my strip. I hope i can figure it out or else maby redesign my ligt diffuser to simple square
It is your choice to go with the Adafruit library or FastLED library. Either one will do for simple animations.
Don’t worry too much about ‘figuring it out’ because you will. I do not know why you want that hexagonal shape but do not let some small added design complexity scare you out of the final result you envisioned!
Just proceed with small steps and when you get stuck, come back here with more specific questions. If you selected the FastLED library, somebody here will help you !!
For the biginning just handle it as a virtual 12x6 matrix and the write a function, that picks the data from the virtual matrix and writes it into your real framebuffer.
Like a NUM_LEDS long list of
leds[number]=virtual[XY(x,y)];
Yes—and in my pixel() (or is it called getPixel()?) method I use that array as a look-up table; if the y value of the pixel I’m trying to address is bigger than the max y for that x value, I return a “dummy” pixel that the caller can operate on with no effect.
You will need to do something slightly more complex but you could adapt this technique.
I believe that this is the code that shipped with the “ROB shades” on Kickstarter-- the layout of the pixels on these glasses was sort of like a matrix, but with “holes”. The technique here might help you, too.