Addressable LED Strip Hookup Guide

Pages
Contributors: Nick Poole
Favorited Favorite 11

Light Up Your Life

Nothing looks as festive as a bunch of bright, colorful lights concentrated into a tight space. And for that, I heartily recommend an addressable LED strip. It's very bright, super vivid, and easy to hookup. This tutorial covers all of the wiring and code necessary to light up a single string of addressable LEDs with just a RedStick and a AA Battery Pack.

LED RGB Strip - Addressable, Sealed, 1m (APA104)

LED RGB Strip - Addressable, Sealed, 1m (APA104)

COM-15205
$26.95

Covered in This Tutorial

Required Materials

To follow along with this tutorial, you will need the following parts:

You will also need to following tools:

Suggested Reading

If you've never worked with addressable LEDs or with the RedStick, we recommend checking out these other guides first.

Battery Technologies

The basics behind the batteries used in portable electronic devices: LiPo, NiMH, coin cells, and alkaline.

Light-Emitting Diodes (LEDs)

Learn the basics about LEDs as well as some more advanced topics to help you calculate requirements for projects containing many LEDs.

WS2812 Breakout Hookup Guide

How to create a pixel string with the WS2812 and WS2812B addressable LEDs!

RedStick Hookup Guide

Learn about the SparkFun RedStick, a USB thumb drive-sized Arduino-compatible development platform.

Mean Well LED Switching Power Supply Hookup Guide

In this tutorial, we will be connecting a Mean Well LED switching power supply to an addressable LED strip controlled by an Arduino.

Hardware Assembly

For the purposes of this tutorial, I'm going to assume that you have some very basic soldering experience. There are only a handful of connections that you'll need to solder, so this isn't a bad project to start with However, if you are using this as your introduction to soldering, we strongly suggest reading this tutorial first.

How to Solder: Through-Hole Soldering

September 19, 2013

This tutorial covers everything you need to know about through-hole soldering.

Addressable LED strips, like the one in this tutorial, tend to use a standardized 3-pin connector. This makes it easy to chain multiple LED strips together. Because the battery pack included with this project is not going to support a lot more than the 60 included LEDs, you may find it convenient to cut the female connector off the "out" end of the strip and solder it to the RedStick to make your LEDs detachable.

Warning: **Make sure you're cutting the right connector!** Look at the little black arrows on the LED strip. You want the connector with the arrow pointing *toward* it.

arrow

The diagram below illustrates the handful of connections that you'll need to make. You'll notice that the red and yellow wires from the LED strip are connected directly to the battery connector. You may be tempted to connect them to the GND and VCC pins on the RedStick, but don't do that. The VCC pin draws current through the on-board voltage regulator, which isn't rated for the high current that the LEDs require to operate. If powered from VCC, the regulator will definitely get hot and may fail altogether.

diagram illustrating proper wiring connections

Click image for a closer look

Example Code

Once your LED strip is wired up, you can load some Arduino code onto the RedStick to animate the lights! For our example code, we'll be making use of Adafruit's fantastic NeoPixel library.

Click here to download a copy of both the example code, as well as the NeoPixel library. The library is located in the "Adafruit_NeoPixel" folder, and the example code is found in the "WS2812_Breakout_Example" folder.

You'll need to install the library. For help there, check out our installing Arduino libraries tutorial.

We've broken down the example code into a few separate sketches that each have a fun animation. We've taken the liberty of cooking up a few special addition animations as well:

Rainbow Cycle

This one is my favorite of the NeoPixel example animations. It scrolls through the entire rainbow of colors while evenly distributing the color spectrum across the LED strip.

language:c
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 2

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.setBrightness(64);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
rainbowCycle(20);
}

void rainbowCycle(uint8_t wait) {
  uint16_t i, j;

  for(j=0; j<256*5; j++) { // 5 cycles of all colors on wheel
    for(i=0; i< strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel(((i * 256 / strip.numPixels()) + j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Input a value 0 to 255 to get a color value.
// The colours are a transition r - g - b - back to r.
uint32_t Wheel(byte WheelPos) {
  WheelPos = 255 - WheelPos;
  if(WheelPos < 85) {
    return strip.Color(255 - WheelPos * 3, 0, WheelPos * 3);
  }
  if(WheelPos < 170) {
    WheelPos -= 85;
    return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  }
  WheelPos -= 170;
  return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
}

Candy Chase

This is a little animation that I worked up based on the "Theater Chase" animation included in the NeoPixel example code. It creates a crawling lights effect in red on a white background, like an animated candy cane!

language:c
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 2

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.setBrightness(64);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
candyChase(100);
}

void candyChase(uint8_t wait) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (uint16_t i=0; i < strip.numPixels(); i++) {
        strip.setPixelColor(i+q, 255,255,255);    //turn every pixel white
      }
      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 255,0,0);    //turn every third pixel red
      }
      strip.show();

      delay(wait);

      for (uint16_t i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

Snowflakes

This animation creates an array of randomly twinkling white pixels reminiscent of snowfall.

language:c
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 2

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.setBrightness(64);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
    snowflakes(100);
}

void snowflakes(uint8_t wait) {

// Setup the pixel array
int pixel[60];
for(int p=0; p<60; p++){
  pixel[p] = random(0,255); 
}

// Run some snowflake cycles
for (int j=0; j<200; j++) {

// Every five cycles, light a new pixel
if((j%5)==0){
  strip.setPixelColor(random(0,60), 255,255,255);
}

// Dim all pixels by 10
for(int p=0; p<60; p++){
  strip.setPixelColor(p, pixel[p],pixel[p],pixel[p] );
  pixel[p] =  pixel[p] - 10;
}
   strip.show();
   delay(wait);
}

}

Iceflakes

Not a real thing, I know... It's "Snowflakes" but blue instead of white.

language:c
#include <Adafruit_NeoPixel.h>
#ifdef __AVR__
  #include <avr/power.h>
#endif

#define PIN 2

Adafruit_NeoPixel strip = Adafruit_NeoPixel(60, PIN, NEO_GRB + NEO_KHZ800);

void setup() {
  strip.begin();
  strip.setBrightness(64);
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
    iceflakes(100);
}

void iceflakes(uint8_t wait) {

// Setup the pixel array
int pixel[60];
for(int p=0; p<60; p++){
  pixel[p] = random(0,255); 
}

// Run some snowflake cycles
for (int j=0; j<200; j++) {

// Every five cycles, light a new pixel
if((j%5)==0){
  strip.setPixelColor(random(0,60), 0,0,255);
}

// Dim all pixels by 10
for(int p=0; p<60; p++){
  strip.setPixelColor(p, 0,0,pixel[p] );
  pixel[p] =  pixel[p] - 10;
}
   strip.show();
   delay(wait);
}

}

Extending Battery Life

The 60 LEDs on your addressable LED strip can drain a lot of batteries really fast. At full brightness, the strip will pull over 2 amps!! With a capacity of only 1.5 amp-hours, the AA batteries will only power the strip at full brightness, continuously, for under an hour. If you want to get more bang for your battery-buck, there are a few tricks you can use.

Cap the Brightness

60 LEDs in a linear meter is a lot of LEDs, so running them at full brightness is really... impressive. And mostly unnecessary. Luckily, the NeoPixel library includes a handy function called setBrightness(); which limits the brightness of an LED strip. You'll notice that the examples in this tutorial all include the line strip.setBrightness(64);, which sets the strip brightness to about 25%. You can set it lower before noticing a huge difference in brightness, so play with that number until you find the right balance between brightness and battery life.

Take a Break

Sometimes a cool lighting effect is more impressive if it isn't continuous. Try dropping a delay(); into the main loop so that there's some downtime between animation cycles. Obviously, the less time you leave the LEDs on, the longer your batteries will last.

Cut it Short

Maybe you don't need 60 LEDs. Maybe 30 would do just fine. You can cut a portion off the end of the strip with a pair of standard craft scissors. Just cut across the copper pads in between the LEDs, and now you have another small strip you could use elsewhere. You can always solder them back together if you change your mind!

Resources and Going Further

Now go forth and add lights to everything! It's worth noting that the RedStick is powerful enough to address a lot more than 60 LEDs, but you'll need to beef up the power supply before you start chaining strips together.

Need more LEDs? Check out these other form factors of the WS2812 Addressable LED strips:

LED RGB Strip - Addressable, 5m (APA102)

LED RGB Strip - Addressable, 5m (APA102)

COM-14016
$96.50
2
LED RGB Strip - Addressable, 1m (APA102)

LED RGB Strip - Addressable, 1m (APA102)

COM-14015
$17.50 $10.95
2

Check out our selection of power supplies, if you need to power more LEDs:

Mean Well Switching Power Supply - 5VDC, 20A

TOL-14098
Retired

Mean Well Switching Power Supply - 12VDC, 12.5A

TOL-14099
2 Retired

Mean Well Switching Power Supply - 24VDC, 14.6A

TOL-14100
1 Retired

Mean Well Dual Output Switching Power Supply (15VDC, -15VDC, 0.8A)

TOL-14101
1 Retired

Did you cut the strip? Check out the LED Strip pigtail connector to easily connect the cut strips:

LED Strip Pigtail Connector (3-pin)

LED Strip Pigtail Connector (3-pin)

CAB-14575
$1.50

For more blinky fun, check out these other great SparkFun tutorials:

Sound Detector Hookup Guide

The Sound Detector is a microphone with a binary output. This guide explains how it works and how you can use it in your projects.

Powering LilyPad LED Projects

Learn how to calculate how many LEDs your LilyPad project can power and how long it will last.

Spectral Triad (AS7265x) Hookup Guide

Learn how to wield the power of 18 channels of UV to NIR spectroscopy with AS72651 (UV), AS72652 (VIS), and AS72653 (NIR) sensors!

Basic Character LCD Hookup Guide

Liquid crystal displays (LCDs) are a great way to output a string of words or sensor data to a display for visual feedback. In this tutorial, we'll learn about LCDs, how to print a string of words to a 16x2 basic character LCD and create custom characters.
LEDs