More than you wanted to know about WS2812 leds
While the Adafruit buttons/leds matrix will save me a lot of wiring, I feel it’s too small for what I’m looking for.
I’m aiming for something like this:
https://learn.adafruit.com/neopixel-arcade-button
Im sourcing most parts from AliExpress, so the BOM so far is quite low.
Regarding the WS2812B, from what I understand they need 5v supply volt but I can feed the digital input with 3.3v logic, right?
I’ll be powering the unit with a USB battery supply
Basically in terms of WS2812B's, it is complicated. And as somebody who has used neopixels/ws2812b's for awhile, I've seen some of the issues (often called 'grumpy' neopixels back then).
Over history there have been two major versions (the original WS2812B version, plus modifications made by that designer over time, and the newer SK6812 versions). Note, what you get, may depend on the whim of the people packing up the LEDs, whatever supply chain issues currently exist, maybe the phase of the moon, etc.
Note, I'm a software guy, not an EE, and follows is how I understand the various ramblings about WS2812B compatible LED strings.
The original WS2812B's were very strict in terms of voltage. IIRC, you had to have the voltage between 4.5 volts and 6 volts (maybe 5.5 volts). The data signal had to be of the same voltage as the power signal. For the original Arduino Uno (using the AVR 328p) which ran at 5 volts, this was great. You didn't need any voltage shifting.
As 3.3 volt microprocessors (like Teensy LC/3.x/4.x) have pushed 5 volt microprocessors out of the limelight, and with the increased use of single cell lithium-ion batteries (nominal voltage 3.6-3.8 volts, maximum voltage when freshly charged around 4.2-4.4 volts) some ws2812b LEDs would not run reliably.
Because the original WS2812 compatible LEDs really wanted 5 volts, often microprocessors being fed off of USB would feed the USB power to the LEDs to give them the 5 volts that were called for. But they would feed the data pins at 3.3 volts. In general, circuits if a data pin is about 70% the voltage of the power level, it will be read as HIGH, and under 70% will be read as LOW. But in cases like this, the world isn't digital. Some devices may read 60% as being HIGH, while others would want 70% (or maybe more). And if you do the math, 5 volts * 0.70 is 3.5 volts. And note, USB sources do vary, with voltages going from around 4.8 volts to 5.2 volts. If the power is 4.8 volts, 0.70 times that is just around 3.3 volts, while if the power is really 5.2 volts, it would be 3.6 volts.
Back in the day, on one of my first WS2812 projects on a 3.3v processor, I found with the microprocessor I was using and the particular 16 LED ring I had, when I was doing the programming, the LED ring would not run off of USB power, but if I unplugged the microprocessor from USB and plugged in a lithium-ion battery, it would work fine. So I had to program the pattern, switch to battery power, do the action, and then switch back to USB to do more programming.
So people started adding level shifters to convert the 3.3 volt data pin to be the same as the power voltage. Here the problem is speed. The WS2812 protocol is a single wire protocol, and the producer has a very tight window to produce the next set of bits for the LED. The garden variety of level shifter that is typically made for slower I2C, SPI, and UART buses is often too slow for WS2812. There are faster level shifters that are single direction that are recommended if you are driving WS2812 LEDS.
Then WS2812 LEDs got a competitor (SK6812) that uses the same protocol. But the SK6812 strips changed some features. They made the minimum voltage lower, so that you could often drive the LEDs directly off of a 3.3 volt bus (though I suspect that at 3.3 volts, the blue/green colors might not be the same as if you used 5 volts). But more importantly for cosplay projects, you could use a lithium-ion battery instead of USB. The sk6812 designers also made the voltage where the chip decides if the data is high/low to be somewhat lower. Finally, while it doesn't affect timing, I believe the PWM rate used by the SK6812's is much faster than WS2812's which is friendlier to people that are sensitive to blinking lights, such as people with epilepsy, migraines, etc.).
This means that often times, you can drive a few SK6812's using the 3.3 volt power bus instead of 5 volt VIN. You have to be careful not to overload the power that the Teensy VIN to 3.3v power regulator can supply. And you don't need the level shifter.
There are two other issues that are often mentioned:
- Some power supplies are not clean, and it is recommended to put large capacitors near the power source to the first WS2812/SK6812 led. These capacitors act as a battery, and will smooth out minor power distrubances. Adafruit recommends a 500–1000 µF at 6.3V or higher capacitor.
- There is a problem of 'ringing' that it is recommended to put a resistor inline between the data pin and the first WS2812/SK6812. Adafruit recommends a 300 - 500 ohm resistor, while other things that have the resistor (like the octows2811 shield) seem to use a 100 ohm resistor.
I've actually built up a test jig that I can feed several different power sources, I have two different level shifters, with/without capacitors, and outputs with/without the resistor. Using jumper wires, I could test the results of different solutions But when I tried it, I couldn't get things to start failing.
And as I said, LEDs with SK6812's seem to work better than the original WS2812's (but I believe WS2812's are being improved, and perhaps newer generations fix the original problems). Since I buy the majority of my LEDs from Adafruit, and they have switched over to SK6812, I see the issues less often. But note, I generally only run a few leds (up to 32 or so). If you were to do 100 or 1,000's of leds, you likely have to pay more attention to getting the details right.
But these days with supply chain issues, perhaps one set of leds uses modern SK6812's and another uses some old WS2812's that have been sitting in a warehouse for 10 years.
In general, if you want to be bullet proof, you would want:
- Add the capacitor near the first LED in the string;
- Add a resistor between your circuit and the first LED data input;
- Feed the leds 5 volts;
- Use a known good level shifter like the 74AHCT125 (I believe the 'T' in the 74 series means it is fast enough).
But if you don't want to do all that, test the stuff you get, and see if it will work. Maybe you will get lucky. On the other hand, if you let out the magic smoke in the leds, and you have to replace it, perhaps the next strand won't be as tolerant.
Oh and have fun!