Individual LEDs vs addressable strip for status indicator?

I have an ESP32 based project in which I’d like to have a visual indication of a 16 bit ‘machine state’ flag. I could do that with 16 individual LEDs driven by a couple of 8-bit shifters (not enough spare GPIO pins on ESP to do directly + excessive current load). That would be a fair bit of wiring + complexity in getting everything into a small enclosure.

It occurred to me that I might be able to achieve the same thing by using a chain of addressable LEDs. I don’t know much about these devices, but from what I can gather they can be controlled from at most 2 pins (data and clock) and given that I can supply power externally it seems a simpler solution.

Is there any reason why I shouldn’t go down that route? Why doesn’t everyone do it like that? Or maybe they do!

Hi, @chaoticbob

Yes that would be the best solution.

This may help.

Tom.... :smiley: :+1: :coffee: :australia:

Thanks Tom, both for the reassurance that it wasn’t somehow an insane way of doing it and for the link. Appreciated.

Bob.

65,000 states? Or just 16?

How many do you have spare?

For up to 20 ordinary LEDs you could do it with 5 pins. (And no extra chips.)

The reason people don’t do it is simply due to not knowing or being stuck in their processes and not thinking about it.

I’ve been known to use an addressable LED simply because I didn’t want to add a resistor. Other than cost, I don’t have many reasons to keep using the non-addressable type.

Thanks for further replies.

PaulRB Potentially 2^16 states I guess! The LEDs are intended to be a visual representation of a 16-bit internal status word.
I have 4 spare pins at the moment but that’s a conservative estimate based on the pins that are marked as ‘always safe’ at ESP32 Pinout Reference .
Thanks for the nudge towards ‘Charlieplexing’ which I assume is what you mean when you say 20 LEDs can be controlled with 5 pins. If so you will know that the technique, though ingenious, has some drawbacks - not least wiring complexity. For me I think shift registers would be more straightforward both for wiring and coding. But addressable arrays now seem preferable in both ways.

cedarlakeinstruments Thanks - being somewhat new to this I thought there must some fatal flaw in my thinking. Seems not! I’ve now bought a 1 metre string of 60 WS2812B chips and they work fine. And have the bonus that if ever I want to confuse myself utterly I can make my status word uint64_t and represent different ‘substates’ with different colours without any additional wiring penalty and minimal extra coding.
Bob.

If the "square" look of the WS2812 is not what you want, try 5mm "LED-shaped" APA106 addressable RGBLEDs on Amazon.

Or use WS2812D 5mm round, from AliExpress. Drill 5mm hole(just like traditional 5mm LEDs), glue in LED(I prefer hot glue), add 0.1 uF capacitor and 75 ohm series resistor as needed, run 5V, GND, Data in to the first one, out to in for the rest. Super simple.
It really depends on what your application really requires. Each LED could also be mounted on it's own tiny PCB, allowing all sorts of physical arrangements.

In my case, I run the LEDs in a (reasonably dark) basement, so my "white" consists of 3 0x10 data bytes. By that, I mean I'm running the LED at 1/16 of full brightness; so, 16 of them would consume 60 mA (typical single LED, Full on). If your environment is bright, you'll have to scale up the 5V current requirements appropriately.

xfpd & camsysca Thanks both for suggestions. Round LEDs would be better for my application, I was wondering how I would mount the square ones. I’m in the UK and looking at the APA106s from Amazon it seems they ship from the US so are quite expensive (£36 / 100), not prohibitive, but AliExpress cheaper. Anyway, now I know these things exist I can look around. I expect they all come from China ultimately!

Cheers, Bob

These are not a must. They are expensive. Search for round, 5mm, WS2812 as @camsysca said... with any online delivery, or if you have one, a local hobby shop.

Don't some of them come on a flexible strip with adhesive back?

Tom.... :smiley: :+1: :coffee: :australia:

Not speaking for our OP, but in my case, the small square ones would have to be mounted behind a panel hole anyway, and (perhaps) the panel hole then filled with something translucent, or clear. The four wire connections can then be made. Primary advantage of these units is that they already have the SMD capacitor and series resistor mounted.

The round classic LED (the ws2812D is available in 5mm and, I think, 8 mm versions) have four legs that can be wired as you please once the LED is mounted. In my case, a button and two LEDs need to be mounted in a specific, consistent pattern, so it was simple to have a 12mmx25mm board made to guarantee alignment while holding the R and C, providing connection holes in a convenient pattern.

Mounting is a breeze - drill the hole for the button and two holes for the LEDs, install the small PCB, hot glue around it to stabilize it, then make the necessary connections.

Hope this helps.