Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 6 of 6

Thread: ws2811 library individual leds address question

  1. #1
    Senior Member
    Join Date
    Feb 2018

    ws2811 library individual leds address question


    for an art project i will insert 60+ ws2811 leds (12mm,blurred) into a white wall. i will use these here (probably two strips):

    since the holes are further apart then the strip allows i will cut the three wires and prolong the connection in between.

    the following question popped up.

    if i cut the 50 pieces apart and put them back together, does the order matter? i know i can have a rail for 5v and GND and just run cables to each individual LED, but what about the programming pin? do i start at one LED and go sequentially to the next? do i have to keep the same order they came in? or is order defined by the leds themselves? (some variable that counts up each time the control signal passes thru a LED-IC for example). before i start cutting those up it would be great to know


  2. #2
    The order doesn't matter with the WS2811 protocol. Each LED effectively works by "taking one signal and passing the rest on", so what you are planning to do will work no problem. Yes, you will have to reconnect all the LEDs serially from start to finish. The exact order doesn't matter other than for the software that you use to drive them - if you're laying them out in anything other than a linear strip you will need to provide some sort of mapping so that your patterns can be mapped to the appropriate LED in 2D/3D space.

    Note that as of fairly recently there are various cheap LED strings on the market that do have hard-coded addresses for each LED and as a result can be trickier and more limited to work with (and are almost always bundled with their own controller), but the LEDs you have linked to look just fine.

  3. #3
    Senior Member
    Join Date
    Feb 2018
    Thanks, that’s great to hear!

    After a meeting with the museum they also want a big countdown on the wall. I think I will order 6 or so of these:

    If I use the octows2811 library, will it be more or less straightforward to display a countdown on them in big letters? i can spend some time on it, but not too much… also I am unfortunately not at my computer, so can’t check the examples right now…


  4. #4
    Senior Member
    Join Date
    Feb 2018
    Or is the octo library only really working with strips, and not squares? I think the squares would probably give me a more consistent look…

  5. #5
    Each square is really just the same thing as a 256 long LED strip laid out in a zig-zag pattern, as you can see from their diagram. The OctoWS2811 library doesn't care about the layout of your LEDs, it just provides a way to very quickly read and write the LEDs via an underlying buffer, where each LED is referred to by a unique index. You could for example attach the data line of each panel to a different Teensy 4.x pin and configure OctoWS2811 appropriately, then call setPixel(n, r, g, b) to set LED number n, where n ranges from 0 to 1535. If your panels were in a row, i.e. 96 x 16, it would be up to your code to map a given X,Y coordinate to the appropriate 0..1535 value. It's pretty easy to do that via either a bit of math or a lookup table.

    As an aside, note that powering 1536 pixels is not something to be taken lightly; you will need a beefy power supply and take care with the appropriate power injection and grounding if you intend to light a lot of them up at once at anywhere near full brightness. All of them on at full bright white will potentially require 60mA * 1536 = 92A of power!

  6. #6
    Senior Member PaulStoffregen's Avatar
    Join Date
    Nov 2012
    Look at the xy() function in the OctoWS2811 examples.

    This is the one from the File example (in Arduino, click File > Examples > OctoWS2811 > Fire)

    // A simple xy() function to turn display matrix coordinates
    // into the index numbers OctoWS2811 requires.  If your LEDs
    // are arranged differently, edit this code...
    unsigned int xy(unsigned int x, unsigned int y) {
      if ((y & 1) == 0) {
        // even numbered rows (0, 2, 4...) are left to right
        return y * width + x;
      } else {
        // odd numbered rows (1, 3, 5...) are right to left
        return y * width + width - 1 - x;
    This code allows the rest of the program to deal with the LED's X,Y coordinate. It translates the coordinate into the index along the 8 strips. If you use a different physical layout, the idea is you can just figure out the math or if-else logic just once, then all the rest of your code can use X,Y coordinates without worrying about how the LEDs are physically arranged.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts