Minotor

WLED matrix mapping: fix mirrored and zigzag pixels

2026-12-02 · Minotor editors

WLED can address a strip in an order that differs from the way it is soldered, which is how a single chain becomes a matrix. When the picture lands wrong, the shape of the error tells you where to look. Rows that alternate direction point to serpentine wiring. A picture mirrored left to right usually means the chain enters at the opposite corner. A picture that breaks at a fixed column and slides further on every row points to a width setting that does not match the panel, and that one is corrected in LED settings before any map is written. The chart and the six-pixel panel below sort those cases with arithmetic you can check by hand.

What ledmap.json controls

WLED remaps a strip in software, so a chain wired in one physical order can be addressed in another. Matrix layouts and serpentine runs both depend on that. You create the file on the device's editor page, which is the device address with /edit appended, and name it ledmap.json. Inside sits a JSON object with a map key holding an array of numbers. Indices start at zero. A two-dimensional layout also carries width and height, and -1 stands for a position with no pixel behind it.

Two details from the WLED mapping documentation are worth knowing before you start. The ArduinoJSON parser is unusually sensitive to white space, so a file that appears to do nothing may only hold a space in the wrong place. And when ledmap.json exists, WLED ignores 2d-gaps.json, which is why a gap layout can stop working the moment a map is added.

Every number below is arithmetic worked on paper for this independent archive companion. No panel was measured. The mapping file is a WLED feature, covered here as an alternative hardware path alongside the Minotor material.

Read the row order before writing numbers

Bring the panel up on a solid colour first and confirm that every pixel responds, then display something whose left, right, top and bottom you can tell apart. The chart below is an editorial diagnostic rather than a manufacturer table. Match the symptom before editing anything, because several of these faults look alike on a small panel.

What you seeWhat it tells youWhat to change
Every second row runs backwards, the others read correctlyThe chain is serpentine, alternating direction on each rowReverse the odd-numbered rows in the map
All rows are reversed, but top-to-bottom order is correctThe chain enters at the opposite horizontal cornerMirror every row
Rows read correctly, but the top of the image sits at the bottomThe chain starts on the bottom rowReverse the row order
The image breaks at a fixed column and shifts further on each rowConfigured width does not match the physical column countCorrect width and height first, then map
Geometry is right, green displays as redColour channel order is wrong: WS2812B and relatives use GRB, WS2811 usually RGBChange the colour order in LED settings
Only the first 30 pixels lightWLED defaults to an LED count of 30Raise the count in LED settings

A 2x3 index map you can check by hand

The smallest panel that still shows serpentine behaviour has two columns and three rows. Logical positions in a row-major grid follow L = y * width + x, so the layout the firmware draws is:

logical grid (width 2, height 3)
y=0:  0  1
y=1:  2  3
y=2:  4  5

Wire it as a serpentine entering at the top left. The chain runs right across the first row, drops down, runs left across the second, drops again and runs right across the third. Chain indices then sit like this on the same panel:

chain order on the same panel
y=0:  0  1
y=1:  3  2
y=2:  4  5

Three lines of arithmetic convert any chain index n. The row is y = floor(n / 2) and the position inside that row is p = n mod 2. On an even row the column is x = p; on an odd row it is x = 1 - p. The map entry is 2y + x.

Two pixels carry the whole lesson. For n=2: y=1, p=0, odd row, so x=1 and the entry is 2*1+1 = 3. For n=3: y=1, p=1, so x=0 and the entry is 2. Rows 0 and 2 map onto themselves. The finished file reads:

{"map":[0,1,3,2,4,5],"width":2,"height":3}

Mirror, vertical flip and reversed parity

The remaining faults reuse the same arithmetic with one term changed, still on six pixels. A horizontal mirror replaces x with width - 1 - x on every row, turning the identity map into [1,0,3,2,5,4]. A vertical flip replaces y with height - 1 - y and gives [4,5,2,3,0,1]. If reversing the odd rows made things worse in a tidy, regular way, the first row probably runs right to left, so reverse the even rows instead: [1,0,2,3,5,4].

All four maps, serpentine included, only swap pairs of entries. Apply any of them twice and the original order returns. That symmetry is convenient on a small panel and misleading on a larger one, because a pair swap produces the same file whichever direction the array is read in. A rotation, an offset run or a gapped shape has no such symmetry, and there the direction starts to matter.

Settling the map direction with a one-pixel probe

The mapping documentation describes the array position as the natural strip order and the stored value as the new position. Its gap example can also be read the other way round: a 9 by 5 array of 45 slots holds the numbers 0 to 15 among -1 entries, which looks like grid slots holding chain indices. Pair swaps hide the difference. Check it on the device in front of you instead of assuming.

This editorial probe uses the documented gap value to leave one pixel addressable:

{"map":[-1,0,-1,-1,-1,-1],"width":2,"height":3}

One pixel lights. If it is the second pixel of the chain, the array is indexed by chain order and the value is a grid slot. If it is the first pixel of the chain, the array is indexed by grid slot and the value is a chain index. Move the single 0 to another position and repeat once to confirm, then write the full map in the direction you saw. Keep the file compact while testing, since the parser dislikes stray white space.

Faults a map cannot fix

Flicker and wrong colours survive any mapping change. WLED's FAQ lists a missing common ground between supply, pixels and controller, a 3.3 V controller driving 5 V pixels without a level shifter, and an overlong data wire. The fixes for those sit in our note on WS2812B first-pixel flickering. Pixels that turn brownish towards the far end are losing voltage along the copper, and power injected at the middle or the end of the run addresses that.

Adafruit's NeoPixel powering guide gives 60 mA per pixel as the worst case at full white, and recommends connecting ground before anything else, with a 300 to 500 ohm resistor between the controller's data pin and the first pixel's data input. One editorial caution: a corrected map can bring pixels into use that sat dark before, so redo the current estimate once the geometry is right. Our amps and watts per pixel calculation covers that arithmetic.

For readers arriving from the clock-and-data side of the archive, WLED's supported hardware list includes two-pin chipsets such as APA102, SK9822 and WS2801, and it notes WS2801 on gpio0 and gpio2. The chipset trade-offs are in WS2801 vs WS2812B, and the wider controller setup is in WLED and LedFx on a WS2801 matrix.

Keeping the map after a reboot

Recent WLED versions accept several maps named ledmapx.json, with a number in place of x, and a preset selects one through {"ledmap":x}. One controller can therefore hold a serpentine map for one panel and a progressive map for another. Segments are not persistent by default, so save the arrangement as a preset and set that slot as the boot preset in LED settings. Without that step, a power cycle brings back the arrangement you thought you had replaced.

Questions and answers

Why is my ledmap.json ignored?

Start with the name and the parsing. The file has to be called ledmap.json and created through the device's /edit page, and the ArduinoJSON parser is very sensitive to white space, so a stray space can stop the map applying. An existing ledmap.json also causes 2d-gaps.json to be ignored, so gaps defined in that second file stop taking effect.

What does -1 mean inside the map array?

It marks a gap, a blank or a null LED. The documentation uses it in a 9 by 5 grid holding 16 real pixels, with -1 in the remaining slots. The same value makes a useful diagnostic map that leaves a single pixel addressable.

Can one controller hold maps for two panels?

Yes. Extra maps are saved as ledmapx.json with a number replacing x, and a preset switches between them with {"ledmap":x}. Set that preset as the boot preset in LED settings if you want it applied at startup.

Sources

Checked 1 December 2026.