LED Controller
I got these lights to put under cabinets because it's dark and I can't see. But the controller it came with wanted me to make an account to be able to turn them on. With a bit of jumper wire I was able to tell that I liked the warm white LEDs that were on the strip and wanted to use the lights, just not the controller. So I set out to build an LED controller for this strip. I’ll walk you through how I did it.
Supplies
I used several very common parts to build this controller. I already had nearly everything for this project on hand.
Materials
None of the links below are affiliate links.
- ESP32 - or another micro controller, Pro-Micro, Teensy, Arduino Nano
- Bread board
- Wire
- Transistors
- 1K resistors
- Keyboard button
- Buck converter
- Board headers (these often come with boards, for example the Pro-Micro above comes with spare headers)
- Tatazone LEDs
- Case
- Heat shrink*
- Zip ties*
- Hot glue*
*optional
Tools
- Soldering iron
- Wire cutters
- Wire stripper
- Screw driver
- 3D printer
- Hot glue gun
- multi-meter
I printed a case for this but anything could work, or even just sticking the board on the underside of the cabinet where you won't be able to see it.
From the LEDs I reused nearly all the parts it came with, the power supply, the wires, the LEDs. only stripping out the controller board. This also gave me an opportunity to see what kind of controller they used.
Finding the Right Lights
First up let's take LEDs generally and then at the specific lights that I am using.
Generally there are a ton of different kinds of LED strips that are out there. I'll hit the main points that I considered when choosing lights.
First up was voltage. It's pretty common to find LED strips that run on 12v, and this project would work for them; you would just need a 12v power supply. I don’t really have a lot of insight on what voltage you should used but just know that most microcontrollers, Arduino/ESP32/Raspberry Pi Pico, can’t control anything over 5v, the Pico is limited to 3.3v. That's the main take away from the voltage.
I think the most important thing for me was to look at was the color of the LED. When it comes to lighting there is something called color temperature, typically people will call a light warm or cool depending on the temperature of the light. Colder color temperatures tend to be more blue, while warmer colors tend to be more yellow. To make this more confusing, color temperature is measured in Kelvin, with cooler colors having a higher value than warmer colors. For example the strip I have has both a warm and cool while LED, the warm white is noted as 2700k and the cool white is 6500k. I’ve included a chart to help give you a better idea of what temperature corresponds to what k value. RGB LEDs tend to have a very cold white so for me it was important to get a strip that either had an additional LED that was a white, and specifically a warm white. These are generally called RGBW strips, this can either mean they have 2 LEDs at every location, one RGB LED and one white LED, or I found some strips that have what they call a 3+1 LED or a single LED that has red, green, blue, and white in one.
Next up is strip density, or how close each LED is to each other, for the LEDs I got the spacing is about 35mm which provides a good amount of light. You can also get strips that have the LEDs closer to each other, or farther apart. I would recommend closer if you need even more light than I have. I don’t know that I would go with a strip much less dense than what I have for any projects. This also plays a role in where you can cut the LED strips if you need to. As most strips have locations where you can cut and most of them tell you that length. For the strip I chose that was 166.7mm, so keep that in mind if you have really tight length requirements.
Now to the LEDs I have. I got these 24V RGBWW LEDs off amazon they have not 2 but 3 LEDs, one RGB, and 2 white, one cool and one warm. Initially I had planned on just using the controller they came with but when they arrived and I went to set them up I found they wanted me to either install an app or make an account with this random brand to be able to even turn on the lights. I was about 2 seconds away from returning them when I decided to at least check out the white colors to get a better idea of what I was looking for. So I hooked up the 24v power supply to the white LEDs and found it was actually a pretty good warm white color. I then took a look around at replacing the LED controller and found that 5 color controllers are not very common, and also had several of the same issues these strips had. So I decided to go for the next best thing and just ya know, spend another $20 and about 2 weeks making my own controller. Because that's logical obviously. I mean I guess lucky for you, if I’d just used what it came with I wouldn't have made this and added my experience on top of the 1000 people who have already done this.
Tearing Apart the LED Controller
On the LED controller I wanted to re-use the barrel jack connector and the LED wire connection. To get at them you could snip the wires but popping the housing open is easy enough with a flat head screwdriver. So I popped the cover off and used my soldering iron to reflow the solder and pull each wire free. I did end up removing a bit more of the shielding from the LED wire so that I had longer bare leads. To get them ready to put into the circuit, I soldered the bare ends to sections of pin header I had. A section of 2 for the power input and a section of 6 for the LEDs. That way it will be easier to remove and reinstall them in the bread board, than trying to line up six separate small gauge stranded wires.
With the wires free and the header added I covered the exposed wire in hot glue to make sure there would be no shorts, the hot glue adds a bit of rigidity to the connector as well.
I reused these parts because what the controller came with is better than anything I will be able to make, and cheaper too, I already have it. And the controller for the LEDs was going into the garbage anyway so why not reuse as much of it as possible.
Building the Circuit
The next step was to build the circuit. Each color needs a transistor, and resistor. The transistor acts like a switch. I can tell it when to turn on using the ESP32 by pulling one leg high. The transistor then completes the circuit it for the LEDs and they turn on.
I can’t connect the LEDs directly to the ESP32 because the ESP32 is not able to handle the 24v that the LEDs need to function. If you were to try to hook them up directly using the LEDs grounding them through the board would let the magic smoke out of your control board. This is true of 12V or 24V LEDs. So transistors it is. Basically they just allow you to control a higher voltage signal using a lower voltage. I chose to use a breadboard for the final circuit board on this project. Typically, I will use a breadboard as a first step and then re-solder wires directly to components. As this project was using a higher voltage than I have used before I decided it would at least need a circuit board, I didn't want all the components just flopping around in a case. And I was most comfortable with using a breadboard for this. Just in case I want to make any changes to the circuit in the future.
I started by putting the ESP32 in the board and then adding the transistors and resistors. With the transistors stuck into the bread board I began the tedious process of cutting wires and making all the connections. To the ESP32 pins ground and 24v. To tell the system when to change the color or turn the lights off, I added a button, it's a left over button from when I built a Macropad a while back, but any momentary button or switch will work here. I soldered some wires on and covered the exposed copper in heat shrink (optional).
For the buck converter I soldered on wires for the input and output ports. Before connecting the output wires to the ESP32 I connected the input to the 24v power supply using the breadboard. I then used my multimeter on the output pads and a small screwdriver to adjust the voltage output down to about 4v for the ESP32 to use. I’ve found some sources saying it can take up to 7v but with only a few ESP32s on hand and a global chip shortage I wasn't about to take any chances. So with the voltage set I soldered the output wires to the VIN and GND ports on the ESP32 and plugged it in and waited for the smoke to escape. (I always assume my projects are going to break on the first try). When that didn't happen, I connected the 24v lead from the power input to the power rail on the LEDs. (I’ve included a diagram of the working circuit)
Code
We must now take a diversion for the circuit to talk about the code. The code here is based on the blink sketch with a bit of input from the button example. It just waits for a button press then turns on the next LED in the list. I also added a custom color at the end, purple, so when it reaches that it turns on two of the LED colors at the same time.
I haven't added any way to dim the lights or change to a different color than what is already hard coded. Take a look at it below.
#include "Bounce2.h" int leds [5] = { 5, 23, 18, 21, 22}; int button = 4; int ledState = -1; Bounce bounce = Bounce(); void setup() { for(int i = 0; i < 5; i++){ pinMode(leds[i], OUTPUT); digitalWrite(leds[i], HIGH); delay(1000); digitalWrite(leds[i], LOW); } bounce.attach( button , INPUT_PULLUP ); bounce.interval(50); } void loop() { bounce.update(); if(bounce.changed()){ Serial.println("Button pressed"); int debounceInput = bounce.read(); if(debounceInput == LOW){ if(ledState < 5){ digitalWrite(leds[ledState], LOW); ledState++; if (ledState == 5){ digitalWrite(leds[1], HIGH); digitalWrite(leds[3], HIGH); } else { digitalWrite(leds[ledState], HIGH); } } else if(ledState == 5) { digitalWrite(leds[1], LOW); digitalWrite(leds[3], LOW); ledState = -1; } } } }
Uploading the Code and Troubleshooting
Ok, back to the circuit, I removed the 24v input power and connected the ESP32 to my computer to upload the code, then removed the USB cable and reconnected the 24v power, again waiting for something to explode. To my surprise the only issue was that all the LEDs turned on. I mean that's good but not what I was looking for. So I checked the code. After finding no issues there I moved on to the circuit.
It took me a few minutes but I found that the big metal tabs on the back of the transistors are not isolated from the pins totally. This means that when one color is on, all of the colors are able to turn on. So when I bent one out of line with the others, that color would turn off. This was a pain to fix but simple enough, just move the transistors so that the metal backs are not touching one another. This created two rows of transistors to ensure that none of them were touching.
Case Design
After everything was finished and working how I expected, I took some overall measurements of the boards and printed a case to go over them.
I 3D printed a simple box that is a press fit. The cover allows me to access the USB port if I ever want to change the code that’s on the controller. One thing to note here is that this case is not water tight. So if this were going to be in a location where I was concerned that it would get wet I would have designed the case differently. I think a bit of silicone calk and a waterproof switch could go a long way for that. Don’t feel restricted to what I have made, if you need to make a case that will work for you. But regardless, stick it in the case and the controller is done. I did end up adding just a bit of hot glue to make sure everything was sealed up better, and the first draft of the press fit was a little loose. I have fixed it in the model.
Install
With the controller stuck in the case I was ready to install it in my kitchen. I stuck the case to the wall using a few command strips. I used the sticky clips that came with the LEDs to install them under the cabinets and I used the cable clips to tie up the loose cable and make it look neater. As a quick note this was a roll of about 32' and I only used 8' for this project, so now I have 24' of left over LEDs for a future project too.
And with everything installed it's done. Now just turn on the lights and admire your work.
I’m really happy with how these lights turned out. I know that's more of a function of the LEDs not the controller but wow, these make me so happy.