Go Down

Topic: Programming a Custom Matrix for WS2812B led "strip" (Read 3388 times) previous topic - next topic

TokenThinker

Hello, I'm new to this coding game and I know there are tons of libraries and examples to look from however I was wondering if there was a specific code set to make an Arduino Gemma recognize the array setup of my leds so that I could do custom color codes and designs. Thanks for all ideas in advance.

Below is the way the LEDs are arranged, let me know if you have any questions. Still debating if I will have that single LED on the ends like that but for now it is a total of 60 LEDs. Thanks!!! 


                                             666
                                         5 5. . .5 5
                                       4 . . . . . . . 4
                                 333 . . . . . . . . .333
                               1. . . . . . . . . . . . . . . 1
                               . . . . . . . . . . . . . . . . .
                                 . . . . . . . . . . . . . . .
                                       . . . . . . . . .
                                         . . . . . . .
                                             . . .

INTP

Your little pattern needs a whole lot more explaining.
How did the LEDs get into whatever pattern that is? Are they still one strip or did you cut them up?

PaulRB

If you want to make a diamond shape, it might be easier to make an 8x8 square and then rotate it by 45 degrees. Less wiring to do, but you would need 64 leds and they often come 30 or 60 to the metre. You can get 144 per metre, so a 0.5m strip would be enough, but the whole display would be smaller

As for wiring, you can use "serpentine raster" or "flyback raster" techniques (hey Mike, I used the cool names we discussed!)

Have you thought about the power supply you will use? These leds can be hungry. Get a 5V 4A+ regulated/switch-mode PSU. If the project is wearable, you will need to figure out the best type, size and number of batteries to use and where to hide them. How long would you want the display to run?

There's another problem. The Gemma is based on ATtiny85. It's pretty limited in terms of both ram and flash memory. It will require some careful and clever coding to run 60 neopixels leds with multiple patterns & sequences. I think you should consider an Arduino ProMicro.

TokenThinker

Hello maybe saying a matrix is the wrong terminology.

The idea of the project is a wearable half mask, got the idea from a guy who makes them on r4ve.com
However I wanted to see if I could improve on it a bit. I already have all necessary power and components to make it work. I'm more stuck on the programming part.

@INTP - they are cut up individually then re-solder into a strip to get the desired shape.

@PaulRB-thanks for the idea, I do apologize for the confusion of terminology I am just unsure what to call what exactly I want. 


This is an image of what I am making - (Props for the idea goes out to Sean @ R4VeCustoms)


Grumpy_Mike

Quote
@INTP - they are cut up individually then re-solder into a strip to get the desired shape.
That doesn't answer the question. How are they rewire? What do those numbers mean? Is it one long strip using only one Arduino data output or does each cut up strip have it's own Arduino data output?

What do those numbers mean on that diagram? Are they colours or LED positions in the strip?

Their is a lot we don't know and we need to know it before we can offer sensible answers.

TokenThinker

That doesn't answer the question. How are they rewire? What do those numbers mean? Is it one long strip using only one Arduino data output or does each cut up strip have it's own Arduino data output?

What do those numbers mean on that diagram? Are they colours or LED positions in the strip?

Their is a lot we don't know and we need to know it before we can offer sensible answers.
-They are wired in series, so essentially till one big long strip with one Arduino data output.

-The numbers above the dots represents how they have been broken up into smaller strips then wired together. so 1 stands for one single LED then 3 is a strip of 3 etc.

-Since they are WS2812B LEDs I figured they was a way to tell the program how the strip was arranged, that arrangements is what those dots represents. 

Grumpy_Mike

Quote
Since they are WS2812B LEDs I figured they was a way to tell the program how the strip was arranged, that arrangements is what those dots represents.
Yes that is the secret. You need to build up a list of what number LED corresponds to what position in your matrix. Then you know what number of LED to change to affect what position. Once you know that you can write the code that sets the pattern you like.
There are two ways to do this:-
1) By algorithm - code that sets the patterns
2) By look up table - a copy of what LEDs should be set to what colours.

TokenThinker

Yes that is the secret. You need to build up a list of what number LED corresponds to what position in your matrix. Then you know what number of LED to change to affect what position. Once you know that you can write the code that sets the pattern you like.
There are two ways to do this:-
1) By algorithm - code that sets the patterns
2) By look up table - a copy of what LEDs should be set to what colours.
Thanks a lot for the advice, do you know if there are any tutorials out there to help me understand those coding methods?

Grumpy_Mike

Well they all should be because that is the only two ways of programming. So for an algorithm look at the AdaFruit demo code. Thing is you need a different algorithm for each different patter.

The attached is the first draft of something I am writing that might help explain more:-

TokenThinker

Thank you!! I'm going to read this and play around and hopefully come up with an algorithm or at least a start to try and code these.

I'll post updates later to help those people out later if I figure something out.

L30_

This is fantastic @TokenThinker, I was googling how to do this myself with this exact mask (I'm Sean at R4VE).  Did you ever figure this out?

L30_

The LEDs for this mask are arranged in a serpentine pattern from left to right (see graphic), the numbers represent each LED and the grid is how they're laid out in relation to one another in the physical space.  





I believe the question here is how do you define/map these LEDs as part of a square matrix using FastLED so things such as text can scroll across without distortion.    Using my grid as an example, the matrix would be 13x7, with the first LED sitting at 1,3 - so we need to number the LED at 1,3 as LED 0 - 1,4 as 1 - 1,5 as 2 then 2,5 as 3 and so on.

Grumpy_Mike

#12
Jun 03, 2017, 03:17 pm Last Edit: Jun 03, 2017, 03:22 pm by Grumpy_Mike
Quote
I believe the question here is how do you define/map these LEDs as part of a square matrix using FastLED so things such as text can scroll across without distortion.
I don't think you can.

Basically you have a 13 by 7 column down serpentine raster but incompletely populated.
So what I would do is to create a 13 by 7 array to put your pattern in. You can then manipulate that array to perform things like scrolling, wipes and so on. Note some positions in that array would map to pixels and some would not.

The when you want to display this array you would use a byte lookup table, again 13 by 7 that contained either the LED that the square mapped to or some number that told you their was no LED at that point, -1 is good for that. Then go through your pattern array and get the LED number to use to set the FastLED array or to just ignore.

Go Up