Boost LED Signal Strength with a Logic Level Shifter

When I first started tinkering with LED strips, my experiments were tiny in size. They were mostly built on my desk with a bunch of jumper wires running between a breadboard, a microcontroller, and some LED strips. My exploits so far largely included the following hardware:

Once I started scaling up my projects though, I needed to ensure signal strength and integrity. My first entry point to this was a logic level shifter, which – in this case – takes in a low voltage logic signal on one pin, and boosts it to a higher voltage level before sending it back out on another pin.

Quad Level-Shifter (3V to 5V) from Adafruit

Analysing The Problem

Let’s rewind a touch. It’s one thing to get 30 LEDs sequenced and looking pretty on your table top. But I was moving into the hundreds and even thousands of LEDs, and my data lines were getting a little thicker and longer. I didn’t consider signal voltage at all, and once I started scaling, the problems appeared.

My first bit of research involved me researching a bit more and actually reading through those often scary data sheets. Information can be overwhelming, but you’ve got to start somewhere. After cross-referencing a few internet searches with some documentation on the Teensy and the WS2812B strips, I arrived at the following:

  • The Teensy 4.1 output pins have a HIGH of 3.3V

  • The WS2812B strips are rated at 5V, with a minimum operating voltage of 3.3V

The shortcoming is immediately obvious. If the max voltage on the Teensy is 3.3V, and the LED strips perform optimally at 5V, then you’re in a losing battle to begin with.

The Solution – A Logic Level Shifter

Once I moved from tinkering with prototypes to building actual installations, it meant moving past the basics when it came to circuitry. In the case of working with addressable LEDs and fixing the problem outlined above, it meant figuring out a way to boost my signal voltage, aka my logic level voltage. Luckily for us, that problem is largely solved and readily available in the form of integrated circuits (ICs). There are a few names for these ICs:

  • level shifter

  • logic level shifter

  • voltage level translator

But they all mean the same thing. Best part? They are really cheap. The one I’ve been using, and that’s featured in the image right above, is the Adafruit Quad Level-Shifter (3V to 5V). I recommend these or similar, because they are particularly good for high speed data transfer, which is desirable when working with addressable LED sequencing.

So what does it actually do? Logic level shifters perform one critical task. In this case, it takes in 5V power on one input, the signal (remember it’s a 3.3V signal in our example) on another input, and spits out the same data shifted up to the 5V level. Perfect for our application. Another great thing about these chips? They’re super cheap, often coming in at $1.50 or less. I’ve even seen them go as low as $0.50 on other electronics stores.

I will add, there’s a whole suite of considerations surrounding data integrity once you start scaling up – power supply management, long data lines, number of LEDs per run, etc. Logic level shifting is one of many solutions, gives major benefits at a cheap cost, and is easy to implement.

Wiring Prototype

The cool thing about this particular level shifter is that there’s 4 input/output channels. That gives a lot of flexibility when it comes to project design, because you can use 4 different pins on the Teensy (or your microcontroller of choice).

Side note: if you’re wondering why I’m opting for the Teensy 4.1, it’s because it is blazingly fast microcontroller, and is benchmarked way higher than other typical 32-bit microcontrollers.

If the pic above is too difficult to decode, here’s a schematic that should be much easier to follow.

Wiring schematic for the Level Shifter. PDF version here.

Some Key Pointers

For starters, I didn’t include the Teensy in the schematic above to save space. But each of the labels “To Data Pin X” indicate a connection to the Teensy output pins. You can use whichever pins you like, but I chose 11, 12, 13, and 14.

Next up is looking at the data sheet for the level shifter and understanding the pins. It’s pretty detailed, but the important bits are as follows:

  • Vcc is the supply voltage, and we want 5V. This is actually convenient for us, because our LEDs are also 5V.

  • Gnd means ground. More on that below.

  • Pins ending with an A are data input pins – e.g. 1A, 2A

  • Pins ending with Y are data output pins – e.g. 3Y, 4Y

  • Pins ending with OE are ground pins – e.g. 1OE, 2OE

  • Data in pins correspond to their data out pins by number. Example, the 1A input corresponds to the 1Y output.

  • All grounds should be common, and should be routed back to the Teensy’s ground

Let’s light it up!

Uploading Code, Plugging In, and Turning On

Before actually turning on the lights, we need our Teensy to act as an LED driver. There are many ways to do this, but in this prototype I opted for the FastLED library and one of their built in sequences (that I slightly modified). FastLED is a fast, efficient, easy-to-use Arduino library for programming addressable LED strips and pixels. It’s been around for a long time, is very stable, and has a big community, making it super easy for getting started with LED projects. I used the built in cylon example, modified slightly to run the same sequence on the four separate pins. I uploaded this to my Teensy using the Arduino IDE. Here’s the code:

#include <FastLED.h>

// How many leds in your strip?
#define NUM_LEDS_PER_STRIP 300

// For led chips like Neopixels, which have a data line, ground, and power, you just
// need to define DATA_PIN.  For led chipsets that are SPI based (four wires - data, clock,
// ground, and power), like the LPD8806, define both DATA_PIN and CLOCK_PIN

// Define the array of leds
CRGB leds[NUM_LEDS_PER_STRIP];

void setup() { 
  Serial.begin(57600);
  Serial.println("resetting");
  FastLED.addLeds<WS2812B, 11, GRB>(leds, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<WS2812B, 12, GRB>(leds, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<WS2812B, 13, GRB>(leds, NUM_LEDS_PER_STRIP);
  FastLED.addLeds<WS2812B, 14, GRB>(leds, NUM_LEDS_PER_STRIP);
  FastLED.setBrightness(84);
}

void fadeall() {
  for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
    leds[i].nscale8(250);
  }
}

void loop() { 
  static uint8_t hue = 0;

  Serial.print("x");

  // First slide the led in one direction
  for(int i = 0; i < NUM_LEDS_PER_STRIP; i++) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show(); 
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(10);
  }

  Serial.print("x");

  // Now go in the other direction.  
  for(int i = (NUM_LEDS_PER_STRIP)-1; i >= 0; i--) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show();
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(10);
  }
}

Next up, I removed the USB cable, and hooked up my power source instead. In the prototype, I’m using a single power source for the Teensy, the level shifter, and the LED strips. I used a multimeter to check that I was getting correct signals and voltages in each of the 4 terminal blocks. Then lastly, I screwed the positive, data, and ground lines of each of my strips into terminal blocks, and stuck those terminals into the breadboard. Make sure to match your wires!

And here’s a video of it running. Smooth operator.

Where To From Here?

As mentioned before, logic level shifting is one of many useful solutions when scaling your projects from prototype to production. It performs a specific function, and performs it very well. In the future, I’m sure I’ll run into a lot more problems that need figuring out and then solving 😃 For now, I’ll leave it at that.

Next
Next

Building The Vortex - v1