Thanks, much better answer then I expected.
I'll probably look into SK6812 based LEDs, power them with separate source and use teensy just for control signal.
Note, if you do that you may/may not have some issues. The
Adafruit Neopixel Uberguide Best Practices covers a lot of cases. The guide is perhaps getting a little old, but it pulls together some of the issues. In general, the SK6812's seem to be more forgiving than the WS2812B's. Some of the things you may or may not need to do:
- Be sure to connect the ground between the Teensy and your external power source. For just a few neopixels, I would think using the Teensy VIN pin for power is simpler than an external power supply. If you are doing hundreds of LEDs, then yes you likely need external power supplies.
- Put a 300-500 Ohm resistor between the data pin and the first neopixel to prevent ringing in the neopixels;
- Put a 500–1000 µF at 6.3V or higher Electrolytic capacitor near the first neopixel to even out the power supply;
- Minimize the distance between the Teensy pin and the first neopixel;
- If powering the pixels with a separate supply, apply power to the pixels before applying power to the microcontroller;
- If you are using a 5 volt power supply, you may need a logic level voltage shifter such as a 74AHCT125 or 74HCT245. Note, many other voltage shifters are not fast enough for the neopixel protocol (which has a data pin at a fixed timing window and no clock signal). If you are using a battery which provides 4.2 volts maximum, you likely don't need the voltage shifter. And SK6812's tend to be more resistant than WS2812B's. That being said, it helps to test the actual LEDs that you have since there is sample variation;
- Note if you are mixing different brands or makes of LEDs, the color variation can be apparent between the two. Even if you buy from the same maker (like Adafruit), over time, there may be changes (such as going from WS2812Bs to SK6812s). With the global supply chain issues, it likely will get worse over time. As I recall, the WS2812B pulse their lights at a different speed than SK6812s. IIRC, the SK6812's were friendlier to people sensitive to flashing lights (like people with epilepsy), but I don't recall the differences;
- Also pay attention to the wiring differences. Adafruit sells lots of neopixels where you have to solder connections to the neopixel. But they also sell strips and such with plugs built-in. They have 2 different plugs they use and in one case, they used the same plug as other strips but you attached input to the male end instead of the female end. And the order of the 3 wires can be different (i.e. ground, power, data or ground, data, power);
- I mostly use neopixels in cosplay setups. There due to vibrations during use, I frequently have to resolder connections each time I take out the prop. At one point I was buying neopixel rings with the plug already attached on the assumption their solder would hold better than what I do, but I've had to resolder those as well.
That being said, a lot of times, I don't follow the best practices for powering 32 or so neopixels. It mostly works, but i have seen times where it doesn't. I just built a rig that I can use to see if I need to use the extra steps. Within the rig, I can:
- Select different power supplies;
- Use two different voltage shifters, or don't use either shifter;
- Add 2 different capacitors to the power (one Electrolytic, one a 0.1upf ceramic capacitor);
- Add a 330 Ohm resistor.
While you indicated you were only doing 2 LEDs, if you want to jump into the flashy world of more LEDs, the Teensy has a board that allows you to setup 8 parallel streams of LEDs. This board has all of the necessary level shifters, resistors, etc. IIRC, on the Teensy 4.x, you can actually use more than 8 streams in parallel and use two separate boards:
Alternatively for just a few streams in parallel, you can use the
WS2812Seriall library to run the neopixels via DMA, which is friendlier if you are playing music or running servos because it does not turn off interrupts while updating the neopixel chain.
Finally, if your processing requirements are much smaller, the Teensy LC has one pin (17/A3) that is logic level shifted to VIN on a different output pin in the board. That way, all you might need is a resistor and a capacitor.