A kind of universal driver for WS2812B LED strips automatically determining the number of LEDs on the strip.

Similar projects worth following
My kids like those chemoluminescent sticks but they last only for one evening. So I thought of making something similar from LEDs. Taking WS2812B LEDs allows even to add effects. The idea was to have a device to which I can plug a LED strip of any length (within limits) without having to reflash it.
After the first prototype was running I build some kind of belts which my kids could wear. (They do and they like it!) I had also seen an umbrella somewhere on Adafruit's website. So this was my second use for it. These first prototypes used an arduino nano clone and the circuit on perfboard.


Schematic of the main PCB

x-kicad-schematic - 15.23 kB - 11/27/2019 at 19:46



showing an umbrella with LED strips in action

MPEG-4 Video - 10.86 MB - 11/27/2019 at 17:30



showing a LED strip belt in action

MPEG-4 Video - 10.91 MB - 11/27/2019 at 17:29


  • 1 × 25mm diameter electric tubing (about 17cm)
  • 1 × 18650 lithium cell
  • 1 × 10R or 5R1 or anything inbetween Resistor 0805 SMD
  • 1 × 100nF Capcitor 0805 SMD
  • 1 × Cable to connect LED strip

View all 14 components

  • The software

    MaBe4211/27/2019 at 19:50 0 comments

    The software makes use of the neopixel library to address individual LEDs at the beginning. Afterwards some of the many effects of the WS2812FX library are used. The mcu checks the battery voltage (via internal reference) and shuts down if it drops below a threshold. If the mode switch is pressed after the last available effect, it will also shut down the device. The code is on github.

  • How the circuit works

    MaBe4211/27/2019 at 19:45 0 comments

    There are two switches in the circuit - one as a latching switch (SW 2) to switch it on and the other as a mode switch (SW 1).

    The latching switch circuit : that's Q2, Q3 and SW2. Pushing SW2 puts the gate of Q3 high. This connects the overall ground GND to PWRGND which is the battery ground. Thus the mcu gets a supply voltage and will pull the base of Q2 low. This will keep the gate of Q3 high. SW2 can be released and is not used anymore.

    At the beginning the gate of Q1 will be low. So all current for the LED strip will flow through R2. The mcu now lights LEDs from the start to a defined maximum number (for the moment 200) - one at a time and measures the voltage drop at R2. From this it's easy to find out the number of connected LEDs. Afterwards the gate of Q1 is set high and R2 is shorted by Q2.

    The MOSFETs Q1 and Q3 are obviously over-dimensioned. However, the IRLU024N/IRLR024N is the standard MOSFET which I use in my projects : first it's a logic level MOSFET and second it's reasonably priced. So as long I do not need hundreds of them I see no point in flipping through data sheets for hours just to save a few cents.

  • Prototype

    MaBe4211/25/2019 at 21:27 0 comments

    I build the device into electrical tubing (25mm diameter) which makes a housing which is stable and can be carried around easily, is just big enough to hold a 18650 cell and is very cheap. I added an off-the-shelf LiPo charging board and some cable with a robust connector. For the prototypes the lid (with the USB connector for charging) was manually cut from acrylic and the other end I just sealed with silicone. The circuit for a latching switch, a mode switch and to determine the length of the LED strip was build on perfboard and connected to an arduino nano clone.

View all 3 project logs

  • 1
    Assemble PCB and progam mcu

    Assembly of the PCB is straight forward. To program the mcu I used a modified AVR-ISP-adapter: I had butt-coupled and soldered pogo-pins to a 6pin pin header together with some additional pin-headers for meachnical stability. The mcu can the programmed e.g. from the Arduino software using an external programmer (don't forget to first burn a bootloader to set the fuses of the mcu - the bootloader will be deleted again when the program itself is flashed).

View all instructions

Enjoy this project?



Similar Projects

Does this project spark your interest?

Become a member to follow this project and never miss any updates