A simple, full color upgrade for your LED indicators



Recently, I was working on a project that needed a couple of LEDs on its front panel for status indication. I realize many, if not most, pieces of electronic equipment now use graphic LCDs, Bluetooth to phones or tablets, or connections to PCs for informational display. But some things are way too simple for that, like on/off indicators when a temperature reaches its setting or when there is a short detected. The project I was working on did not need a graphic LCD or other major display but needed a little more than a one-color LED. I needed multiple colors—two wasn’t enough, not even three—four would work. I could use a three-color four-pin LED and mix colors, but I was not enamored with the mixes. What I wanted was a simple solution that would give me multiple color choices along with brightness control.

Wow the engineering world with your unique design: Design Ideas Submission Guide

I used one of those multicolor LED strips before, on a parking assist project and it worked well and was easy to get working. Also, it only needed one digital I/O line (besides the power and ground) which is important if you’re running low on I/O pins. But for this new project, I didn’t need a strip of 100 LEDs, I just needed two LEDs. Also, I was looking for a small solution like a 5MM T-1 3/4 LED. So, what if I took one of the LEDs from the long strip and 3D printed a holder in the shape of a 5mm LED?

First let’s take a quick look at the LED strip I’m talking about. Just search for a “WS2813B LED Strip”. You’ll see that this has 3 pins: +5v, ground, and one data line. You’ll find firmware drivers for a number of processors, but I chose a library called FastLed created for Arduino boards as that was used on the project. Typically, you would use FastLed to talk to each of the LEDS on a strip through the single data line as the data is forwarded to the next LED in line so the data propagates to the last LED. In FastLed, the data is nicely abstracted so, along with many other functions, you can set each individual LED in the strip with unique red, green, and blue (RGB) values. R, G, and B are each given a value from 0 to 255. This allows for a vast number of colors and brightness’s that can be used (essentially all colors of the rainbow). If you prefer using hue, saturation, and value (HSV) in lieu of RGB values, there is a function call for that as well. These LED strips also allow you to cut them to any length. When one is cut out, it is a single LED with solderable patterns on both in and out of the LED, see Figure 1.

Figure 1 Single LEDs cut from a WS2813B LED strip, the wires can be soldered to the single LED, connecting the data line from the Arduino.

Let’s look at how to use these. Wires can be soldered to the single LED making sure to connect the data line coming from the Arduino to the side with the arrow pointing to the LED chip, let’s call this the left side. If you want to test this out quickly, connect the power and ground to an Arduino Nano’s +5v and GND. Then, connect the LED’s data line (middle trace) to D7 on the Nano. Next, load the program in Listing 1 into the Nano and run it. You should see the color changing and then repeating. (Note, you may need to load FastLed.h using the Arduino Library Manager.) See “Program Listing 1” below:


1  #include <FastLED.h>
2 
3  #define LED_PIN 7
4  #define NUM_LEDS 1
5 
6  CRGB leds[NUM_LEDS];
7  uint8_t h = 0;
8 
9  // ====================== SETUP =====================
10 void setup() { 
11  FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
12 }
13
14 // ====================== LOOP =====================
15 void loop() {
16
17  for (h = 0; h < 256; h++) {
18      leds[0] = CHSV ( h, 255, 255); // Set values in the LED
19      FastLED.show();
20      delay(40); 
21  } 
22 }
   

Obviously, this isn’t a panel mount LED yet, so let’s look at the adapter that holds the single LED. Provided in the download location are 3D files for printing the adapter parts. For the 5-smm LED adapter, print the main part of the adapter and the back cover.

First place the cut LED in the slot at the bottom of the adapter (LED chip facing the domed head). This is then held in place by the back cover that slides over the LED (see Figure 2). There is no need for adhesive; in fact, don’t peel off the plastic exposing the sticky back on the LED.

Figure 2 Parts and mounting of the LED into the adapter (a link to the 3D design files for these parts can be found at the end of this article).

The adapter’s main body is printed with a transparent filament (or resin if you’re using that type of printer). I used a transparent PLA and a layer height of 0.12 mm. I tested different percentages for infill and found 15% gave me good light transmission. The sliding back cover can be printed in any color; I used grey PLA and a 0.12 mm layer height.

The top of this adapter is essentially a 5 mm LED shape and dimensions so it can be used with commercial panel mount LED holders. If you’d rather, the LED fits nicely, and snuggly, into a 5 mm hole when using a 3D printed front panel with a 5 mm printed hole—I’ll show an example later.

I also designed an adapter with a square lens, made for panel mounting in a 16×16 mm hole in a 3D printed panel. It is assembled in a similar fashion (Figure 3).

Figure 3 Parts and mounting of the LED into the square adapter (a link to the 3D design files for these parts can be found at the end of this article).

Note that after some testing, the infill of 15% again gave the best light transmission while spreading the light across the full surface. But this is subjective and you may want to try different infill percentages and a different number of bottom layers (the face of the adapter is the bottom of the print).

To test these adapters, I design a test stand that holds one square adapter and two 5 mm adapters. It also allows for the mounting of three potentiometers to adjust colors and brightness. First let’s look at the schematic (Figure 4).

Figure 4 Schematic of the string lights-to-LED adapter where the 5v is supplied by a USB connection to the Arduino Nano and the potentiometers are connected to the three analog inputs to digitally read their positions.

As you can see, it’s pretty simple. There is no power supply as 5v is supplied by a USB connection to the Arduino Nano. The potentiometers are connected to three analog inputs so we can digitally read their positions. The LEDs share power and ground. Also, the D7 pin of the Nano is routed to the first LED, the square one. This should be a connection to the labeled D1 trace, with the arrow, (left side) on the LED strip. Then connect the right side D1 trace the next LEDs D1 with the arrow, (left side). Finish by connecting the right side D1 to the last LEDs left side D1. See this arrangement in Figure 5.

Figure 5 The LED wiring for the test stand where the D7 pin of the Nano is routed to the first LED.

This ordering of the LEDs is used in the c code as the LED wired directly to the Nano’s D7 pin will be addressed with index “0”. The LED connected next will be addressed as index “1”, and the last LED as index “2”.

Now, after 3D printing the test stand’s two parts, it can be assembled using 2 screws as per the schematic and as seen in Figure 6. The square lens can be inserted into the test stand then the next 5-mm LED into the upper hole in the test stand. The last LED can be inserted into the lower hole after installing a bezel. This bezel can be printed from the download files, or it can be a commercial bezel.

Figure 6 The 3D printed test stand to test the effectiveness and esthetics of the adapters. The RGB settings or HSV settings can be adjusted with the control knobs using specific programs.

Using various demonstration programs supplied in the download, you can test the effectiveness and esthetics of the adapters. There is a program to allow adjustment of colors and brightness, using the control knobs to adjust RGB settings. With another program, you can adjust HSV settings. As you adjust the knobs, the digital values are displayed on the Arduino serial output so you can find a color and brightness you want to use and record its values.

I think you’ll find that these adapters will come in handy for many of your projects requiring LEDs. You can not only get a huge selection of colors but you can control/adjust all your LEDs from one control pin. Also, you can have an adjustable brightness without using PWM. As for cost, when you buy an LED strip, you’ll find the individual LEDs work out to be only about 10 cents each.

All files for printing the parts (stl, step, 3mf) are provided in the download location, as are extra pictures, the BOM, and more information. The download can be found at:

Damian Bonicatto is a consulting engineer with decades of experience in embedded hardware, firmware, and system design. He holds over 30 patents.

Phoenix Bonicatto is a freelance writer.

 Related Content

<!–
googletag.cmd.push(function() { googletag.display(‘div-gpt-ad-native’); });
–>

The post A simple, full color upgrade for your LED indicators appeared first on EDN.



Source link