For those of you looking to create a unique and vibrant lighting display, addressable LED strips can be an ideal solution. From changing light patterns that cap off your next Halloween prop to interactive environments and even large-scale attraction set designs – addressable LEDs are incredibly versatile. With the arrival of dedicated LED driver chips on the market, connecting LED strips to microcontrollers like Arduino boards is simpler than ever before with a lot less wiring and code involved. In this first tutorial of my Ultimate Guide to Using LED Strips with Arduino, we’re going to walk through the various types of LED strips on the market, how to choose the right one for your project, best practices for connecting the strip to your Arduino board along with tips on powering it all for dynamic lighting without any prior knowledge about programming or electrical engineering!
How to Choose the Right LED Strip for your Project
One of the most popular LED products on the market is the flexible LED strip. They come in a variety of models with different characteristics but often look so similar that it’s tough to tell the different types apart. For instance, not all LED strips are individually addressable. This means that the entire strip can only display one color at a time and you can animate between solid colors. Addressable LED strips on the other hand allow you to program unique colors for each pixel in the strand so you can produce complex animations like color chasing, sparkle, gradient effects and more! Although this sounds complicated, all the pixels on the strand can be controlled using a single data line connected to a microcontroller like the Arduino.
Types of Addressable LED Strips
There are various types of RGB LED drivers or chipsets available but the most popular for small to medium-sized projects is probably the WS2812B chipset. Other addressable LED strips include WS2811, WS2812 and SK6812 among others but we’re going to focus on connecting and programming a WS2812B LED strip with Arduino in this Ultimate Guide to Using LED Strips with Arduino series. Each pixel in this strand consists of a tiny red, green, and blue LED integrated alongside a driver chip into a tiny surface-mount package.
In addition to the chipset, there are other features to consider when picking out your addressable LED strip. These features affect how evenly spread out the light is between pixels, powering requirements for different the voltage options and whether or not the LED strip can withstand outdoor environmental factors. Let’s take a closer look at each feature so you can select the addressable LED strip that meets your project’s needs.
The density of an LED strip tells you how many pixels are mounted per meter. Popular densities are 30, 60 and 144 pixels/meter. The higher the density, the more evenly distributed the lighting effect. But at the same time, your current draw will also increase because you’re having to power more pixels per meter. With lower density strips like the 30 pixels/meter variety, the current draw is less but hot spots and dark spots are more visible between pixels.
Selecting the right LED strip density for your project also depends on the length of strip you’re planning to use. For instance, if you want seamless light distribution between pixels and only need a short run of strip like for a prop, then going with a 144 pixels/meter LED strip makes sense. On the other hand, if you’re designing a lighting show for a set or attraction and will need long runs, then a 30 pixels/meter LED strip is probably a better choice. For most of my projects, I use the 60 pixels/meter LED strips because it’s a good middle of the road option for getting good light coverage without running into too many power issues.
5V vs 12V LED Strips
LED strips are available in different voltages, the most common options being 5V, 12V and 24V. The 24V strips are a bit overkill for most projects so I’m going to focus on the 5V versus 12V LED strip debate. The 5V strip is easy to start out with for your first projects, especially when you’re only using short strips (less than 100 pixels) and the power source will be within 5 meters from the start of the LED strip. Since you only need 5V to power the strip, you have more external powering options from wall adapters to battery packs. 5V LED strips are also more energy efficient than their 12V counterparts. When you get beyond about 100 pixels in an LED strip you’ll notice a visible change and dimming in color. This is because 5V LED strips are the most susceptible to voltage drop.
What is Voltage Drop in an LED Strip?
Voltage drop happens when the voltage at the end of a given length of wire is lower than at the beginning. Any thickness of wire will have some resistance and running a current through this resistance will cause the voltage to drop. As the length of the wire increases so does its resistance. This explains why the pixels at the beginning of the LED strip are brighter than the ones at the end of a long run – those pixels are simply not getting enough current to work properly.
The good news is that there’s a relatively easy solution to this. LED strips don’t care what end they receive power from. Unlike the strip’s data line that moves signals in one direction only, electricity can go either direction. You can connect power to your LED strip at several points – the start, end or even middle of the strip. This is known as power injection. For best color consistency, try to add a power injection connection at about every meter of strip you use.
If your project requires a much longer run of pixels or you need to connect more than one roll together like in lighting themes for entire rooms, sets and attractions then you’re better off going with a 12V LED strip. Because of the higher voltage, 12V strips are less susceptible to voltage drop and you’ll be able to not only have your power source located further away but will be able to do longer runs before having to inject more power. These can be powered externally the same way as 5V LED strips, either with a wall adapter or battery pack. But because you now need 12V, the battery options are generally more expensive and larger in size.
Indoor vs. Outdoor Use LED Strips
If I know that my project will never be exposed to the outdoors or moisture then I always opt for the indoor LED strips. Indoor LED strips are often less expensive and are much easier to cut and solder into designs because the contacts are exposed. But if there’s a chance that your project needs to be outdoors for an extended period of time then definitely go for the outdoor LED strips. These have a protective silicone sleeve that protects the LED strip’s electronics from moisture and other environmental elements. The main challenge with outdoor LED strips is if you have to cut them and solder wires to the cut edges. You’ll have to cut and peel away the silicone coating on the strip to access the contacts or peel the adhesive strip on the back and access the solder pads from there. Once you make your soldered joints be sure to seal the connection with heat shrink tubing to protect it from outdoor elements.
How to Power an LED Strip
If you’re powering anything more than just a handful of pixels, then you’ll need an external power source. Never try to power an LED strip off your microcontroller like the 5V pin of an Arduino. That pin can continuously supply only about 500mA and each pixel can draw up to 60mA at full white brightness. At this rate you can see how you can exceed the Arduino’s 5V pin limit if using more than just a handful of pixels.
DC Power Supply for LED Strips
If you plan on running your lighting animation for long periods of time then I recommend a 5V DC power supply. Aim for one that supplies at least 2A so you can power a meter or so of LED pixels. It’s always a good idea to over-estimate on the Amp requirements. So long as the output is 5V DC, having extra Amps won’t hurt anything because the LED strip will only consume the current it needs. In addition, a larger power supply will run cooler because it’s not being pushed to its limit for extended periods of time.
I use this voltage-adjustable wall adapter a lot for my projects because it provides 3A which is plenty for LED strips, motors, servos and more but also allows me to change the voltage depending on the requirements for each project. In this case I have it set to 5V for my LED strip.
How do I know how many Amps I need for my LED strip?
Each pixel has three tiny LEDs (red, green and blue) and each can draw up to 20mA at maximum brightness. If you turn them all on to produce the color white at full brightness then you’re looking at 60mA per pixel. This is of course a worst case scenario because when you mix colors for animation sequences you rarely have all LEDs maxed out at the same time so the current draw will be much less.
In order to try and calculate how many Amps my LED strip will draw I like to use 20mA per pixel as a starting point. Let’s say I want to power a 100-pixel LED strip. That’s 100 pixels X 20mA giving me a total of a 2,000mA or a 2A minimum draw. How much overhead you want is up to you but in this scenario, I’d choose a 5V DC power supply that provides more than 2A so I know I’m covered and that I’m not running the power supply at its limit which will reduce its life span.
Battery Options for Powering an LED Strip
For wearable projects or mobile props, plugging your LED strip into a wall and being tethered by a cord isn’t going to work. In this case you have a few portable battery options.
- Lithium-polymer batteries – These deliver 3.7V which is great for feeding low-power microcontrollers but also sufficient for a short length of pixels. Although a bit more expensive than other options, Lithium-polymer batteries are rechargeable and the slim lightweight profile is easier to hide.
- Alkaline batteries – Three alkaline cells like AA batteries in a battery holder will provide 4.5V. Although they’re larger and heavier than the LiPo option, alkaline batteries are inexpensive and widely available.
- NiMh batteries – Four NiMh batteries can be used in a battery holder to provide 4.8V. They are rechargeable like LiPo batteries but the battery pack is a bit bulkier.
Whether you power your LED strip with a wall adapter or battery pack, you’ll notice that it won’t turn on with power alone. You’ll need to connect a microcontroller to the LED strip and do some programming. For the purposes of this guide, we’re going to be covering how to connect an LED strip to an Arduino microcontroller.
How to Connect an LED Strip to the Arduino
You’ve selected an LED strip for your project, a power supply and an Arduino board, so how do you connect these 3 parts together so you can start programming some cool animations? The good news is that it only takes one connection to the Arduino to control all the pixels on the length of strip you plan to use. Let’s go through each connection with tips on best practices to get the best performance and longevity out of your LED strip.
If you look closely at your LED strip, you’ll see some important markings. The first thing you have to do is identify the “input” end of your LED strip. On some strips you’ll see a solder pad labeled “DIN” or “DI” for data input while others will have an arrow showing the direction that data moves along the LED strip. Any digital pin on your Arduino can send data to control the LED strip and you want to connect the end of the LED strip where the arrows point away from the Arduino connection. In other words, you can visualize the data being sent from the Arduino pin into the LED strip and follow the arrows down the length of the strip.
The WS2812B LED strip typically has wires already connected at both ends so not only is it ready to connect to a microcontroller and power source with the wires at the beginning of the strip, but the wires at the end can be used for power injection if you’re using the whole strip. You’ll only need to make three main connections: data wire to an Arduino pin and power (+5V) and ground (GND) to a power source.
Even though you only need to make three connections there are usually more than three wires coming out of each end of the LED strip. Most of the time these extra wires consist of a free-ended power and ground wire for connecting to an external power source and a black connector that also has power and ground but also the data wire. The connectors are there to make it easy to connect more than one LED strip together without having to solder. But in order to connect the LED strip input end to the Arduino you’ll have to cut the connector off to access the data wire (usually the green one).
Connecting the Data Wire
Depending on your project’s design, you’ll often have to connect or solder an extra length of wire to the data line to get it to reach the microcontroller. The closer the Arduino is to the start of the LED strip the better. A meter or two is usually fine and will give you the clearest signal. Much longer runs may cause the data to be unreliable. It’s important to plan out a location for your microcontroller ahead of time while you’re still coming up with the design for your project so you’re not scrambling to try and hide it later.
Place a 300 to 500 Ohm resistor on the data line between the Arduino and start of the LED strip. It’s best if the resistor is closest to the strip rather than the microcontroller. The resistor helps prevent any voltage spikes that might otherwise damage your first pixel. If you run your LED strip without a resistor on the data wire, at some point you may notice the first pixel in your strip go dead and stop lighting up. In the example below, I’ve connected two smaller value resistors in series to get the proper value. I also added more wire length to the +5V and GND wires coming out of the start of the LED strip.
Now you’re ready to connect the data wire to your Arduino. Unfortunately, you can’t just stick a stranded wire into one of the digital pins. To make this connection easy, I solder a jumper wire to the data line so you can connect to the Arduino just like any other component. Don’t forget to protect all your connections with heat shrink tubing.
Connecting the Power Supply
You may have more than one +5V and ground wire coming out of the LED strip but you only to connect to one of each and can trim back the other wires that you’re not using and insulate them with heat shrink tubing. Before connecting an LED strip to any large power source like a wall adapter or large battery, it’s best add a large capacitor in the 500-1000uF range at 6.3V or higher across the + and – terminals. The capacitor buffers or smooths out any sudden changes in the current drawn by the strip. I find myself doing this to all but the sthemallest of my projects just for peace of mind. If using a wall adapter, insert your +5V and GND wires with capacitor into the screw terminals of a female DC power jack adapter in order to connect it with your power supply.
Don’t Forget a Common Ground for External Power Supplies
This last step is only required if you’re using an external power source. Simply connecting the LED strip’s data line to the Arduino and powering it with a wall adapter or battery pack is not enough to get it working. All external components MUST share a common ground with the Arduino. I usually do this by cutting a jumper wire in half and stripping the cut end to expose some wire. I then wrap the end of the jumper wire with the ground wire of the LED strip and put them together into the ground (-) screw terminal of the female power jack adapter. I can then plug the male end of the jumper wire into the Arduino.
Programming LED Strip Animations with Arduino Libraries
With everything connected, you’re now ready to start programming animations for your LED strip! There are several Arduino libraries available for this, the two most popular being the Adafruit’s Neopixel library and the FastLED library. Both can be installed right from within your Arduino IDE. No matter what Arduino library you choose, they’re a powerful tool for programming custom animations from ambient effects to dynamic patterns and both libraries come packed with example code and instructions to get you started.
If you’ve never worked with the Arduino and never coded anything before, it’s easy to get started. Before proceeding on to the next tutorial on programming your first LED strip animations, go through my Arduino Step-by-Step Tutorial for Beginners to get the basics down and then come back and resume this tutorial series.
Have you already played around with the Arduino, comfortable using the Arduino IDE and have a few projects under your belt? Then I hope to see you in the next tutorial where we download and install the FastLED library, go over important functions and program our first LED strip animations.
Some links in this post are to affiliate sites. If you purchase something through them, I may earn a small commission — which costs you nothing! I am very grateful for your support when you use my links to make a purchase.