Project tutorial
Arduino Compatible Nano NeoPixel Controller

Arduino Compatible Nano NeoPixel Controller © GPL3+

Control RGB or RGBW single-wire addressable WS2811, WS2812 or SK6812 LED strands up to the limits of your power or Micro-Controller memory.

  • 17,431 views
  • 1 comment
  • 21 respects

Components and supplies

Ard nano
Arduino Nano R3
Usually includes separate male headers and a USB-A to mini-USB cable.
×1
Adafruit industries ada1609 image 75px
Perma-Proto Breadboard Half Size
×1
Panasonic eca 1em102
Capacitor 1000 µF
Anything around 1000 uF and over 12V DC should do the job.
×1
2.1mm DC Barrel Jack
×1
Resistor 470 ohm
Don't have a 470 ohm resistor? Anything close will probably be fine.
×1
36-pin 0.1" Female header strip
These are optional and allow the Micro-Processor to be easily replaced if necessary
×1
Adafruit NEOPIXELS
Many configurations available -- add as many as your hardware can handle
×1
3-pin JST SM Plug + Receptacle Cable Set
Optional, connects Perma-Proto board to Neopixels
×1
5VDC Power Supply with 2.1mm center positive barrel jack
Make sure you have sufficient Amperage to drive all of your NeoPixels
×1

Necessary tools and machines

Hakko FX-888D Soldering Station
Includes temperature controlled iron, holder and sponge.
Solder spool - 60/40 lead rosin-core solder 0.031" diameter
The thinner the better and the lead melts easier. Use an exhaust fan.
Panavise Jr.
You can't be too rich, too thin or have too many Vices" :)
Flush diagonal cutters
Needle Nose Pliars
Multi-size wire stripper & cutter
Half-size breadboard
Harbor Freight Magnifier Head Band With Lights
You can't be too careful or have too much light on the subject.
7 Function Digital Multimeter
Any decent Multimeter will do, Harbor Freight sometimes gives these away.

Apps and online services

About this project

What is Neopixels

Neopixels, a term coined at Adafruit for RGB and RGBW strands of single-wire addressible LEDs, can be configured in many different ways to make fun and attractive DIY projects.

There are limits to the number of these LEDs that can be controlled by a single Micro-Processor. The two major constraints are available memory and power. Neopixels consist of 3 or 4 LEDs, and a dedicated driver chip. They consume about three bytes of memory each and potentially up to 60 milliamps of current when fully lit. Over the last few years, I have completed several installations consisting of 1 to ~250 NeoPixels using the scalable controller design covered in this project.

Adafruit maintains the most excellent Adafruit NeoPixel Überguide and I urge you to study it thoroughly, especially the Best Practices section, before starting your NeoPixel project and refer to it frequently when prototyping. Specifically, I have incorporated the suggestions relative to using a 1000 uF capacitor to smooth power surges and placing a 470 ohm resistor between the Micro-Controller's PWM pin and the NeoPixels data line.

The Adafruit Perma-Proto 1/2 sized board used in this project allows the components to be assembled in the same relative arrangement used on the breadboad prototype. Another advantage of using the Perma-Proto board is that the rows and columns are labeled like a spreadsheet with lettered columns (A-J) and numbered rows (1-30), a feature we will take advantage of to specify the location of the other components.

If the reader is an experienced Maker, this should be enough information to build or modify the design on your own. To test the project, include the Adafruit NeoPixel Library in your sketch. There are also several test sketches included with the library. The rest of this write-up is intended to go through the project step by step and share some assembly tips.

Getting started

Construction begins by soldering male headers to the Arduino compatible Nano. Use the breadboard as a jig to hold the headers at a right angle while soldering.

Push the male header strips into the breadboard with the long pins facing down, making sure the strips are evenly seated before placing the Nano over the strips. Everything should look even, straight and square before you solder the shorter header pins to the Nano.

It is easier to solder the lowest, smaller components first, so begin with the 470 ohm resistor by placing it's leads through the Adafruit Perma-Proto board holes E12 and F12. It doesn't matter to the resistor what lead goes into which of the two holes. Once positioned, bend the leads on the back side of the Proto-Board to hold the resistor in place. Then turn the board over and solder from the back side. If the resistor doesn't sit the way you want, you can reheat each solder joint while gently pushing on the resistor from the other side until it slips into place.

After soldering, clip the excess leads close to the board using your side cutters.

Next, solder a jumper wire between B12 and B24. I used 22 ga. solid core wire with green insulation because it happens to match the color of the data line in the wiring harness that will go to the NeoPixels. This jumper will eventually connect PWM pin 6 on the Nano to the 470 ohm resistor.

Testing

Use a multimeter to test the connectivity between E24 and D12 and if successful, test E24 to J12. This second test may not result in a 'beep', if you have an audible multimeter, because it spans the current limiting resistor, but the meter should still register a change that indicates connectivity. If you don't have connectivity between E24 and J12, use the multimeter to find the cause and repair it before continuing. I tend to set my soldering iron to 750F and have occasionally 'lifted' traces that connect holes on the back side of the Perma-Proto board. To minimize this possibility, either lower the temperature and/or place the tip of the iron on the side of the hole that is away from the desired current flow and bend the lead of the component being soldered in the direction of the flow. As always, clip the leads when you have finished soldering.

Now solder two jumper wires from J1 and J17 to the corresponding holes on the ground bus of the Perma-Proto board which is identified by an adjacent blue stripe. To hold short jumper wires in place, I wrap a rubber band across the board over the wires to be soldered. After soldering, use your multimeter to test connectivity between F1 and F17. Do the same with two more jumper wires that will connect J3 and i16 to the positive bus, which is identified by a red stripe. Verify connectivity between F3 and F16 before continuing.

Use needle nose pliars to bend the middle pin of the 2.1mm barrel jack to a 90 degree angle. This will help stabilize the barrel jack on the Perma-Proto board. Insert the two remaining pins into holes H1 and H3 with the open end of the barrel jack facing off the edge of the board and solder in place. Verify connectivity from the center pin of the barrel jack to F16 and the grounded shell of the jack to F17.

Plug in a 5V DC center positive power supply into the 2.1mm barrel jack and use your multimeter to check the DC voltage between F16 and F17. The red multimeter probe should be in F16 and the black probe in F17. If you have a digital multimeter and the voltage on the display is preceeded by a minus sign (e.g. -5.16), the polarity is reversed -- either in your project or the leads are backwards on your multimeter. In any event, do not proceed until you can trouble shoot the issue and verify around 5V DC with correct polarity between test points F16 and F17.

The Arduino compatible Nano Microprocessor can be soldered directly to the Perm-Proto board using the male headers you attached earlier. Because of the relatively small size and cost when compared to other Arduino and compatible boards, the Nano has been my go to project board for several years now. I have purchased dozens of Nanos from random Chinese eBay vendors and never had one arrive DOA or go bad. Aside from the hassle of installing the necessary CH340/Ch341 UART drivers for programming the Nano from a Windows PC or a Mac, the Nano is a terrific value in my opinion. However, if there is any chance something could go wrong, it probably will, so I routinely solder female socket strips to the Perma-Project board in order to just plug in the Nano and easily replace it if necessary.

Either cut two 15 pin lengths of female header strip or be lazy like me and just cut a new 36 to 40 pin header strip in half. Push each of the Nano's male headers into the sockets of a corresponding female header strip, trim off any excess and position this assembly on the Perma-Proto board starting one set of headers at D30 and the other at H30. Then hold the whole assembly in place with a rubber band before turning the board over and soldering the headers. Solder each end of the header strips first, check for a good, flush fit and remove the rubber band before soldering the remaining header pins.

The 1000 uF capacitor is most likely polarized, meaning it matters which way it is hooked up. The shorter lead is usually the negative and should be marked with a grey stripe and a minus sign (-). Push the negative lead through the hole in the negative bus (marked with a blue line) associated with row 6 and the positive lead through the hole aligned with row 8 of the bus identified by the red stripe. The capacitor is the tallest component in the project, so if you are using a shallow enclosure, instead of seating the capacitor base on the board, leave enough of the leads above the surface to allow pushing the capacitor over on it's side. Bend the leads over on the back side of the board to hold the capacitor in place, turn the board over and solder the connections. Trim the excess leads. Be careful not to short any exposed leads to each other or another component.

The Neopixels I am using for this project, came with a nice, three wire harness with locking connectors. I soldered the wire going to the Neopixel data connection to J12 on the Perma-Proto board and the positive (+) and negative (-) wires to their respective bus, aligning the positive wire with row 13 on the red striped bus and the negative wire to row 11 on the blue striped bus. It just worked out that the data wire was green, the positive wire was red and the negative wire was blue. All that is left to do is program the Nano Micro-Controller and plug in the power supply.

Code

Untitled fileArduino
#include <Adafruit_NeoPixel.h>

/* changed from #defined constants to variables 2015-12-15 Mel Lester Jr.
	The following two lines are all you may need to change for your project */
int dataPin = 6;	// Arduino PWM data pin D6
int pixels = 64;	// number of Neopixels

// Parameter 1 = number of pixels in strip
// Parameter 2 = Arduino pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(pixels, dataPin, NEO_GRB + NEO_KHZ800);

// IMPORTANT: To reduce NeoPixel burnout risk, add 1000 uF capacitor across
// pixel power leads, add 300 - 500 Ohm resistor on first pixel's data input
// and minimize distance between Arduino and first pixel.  Avoid connecting
// on a live circuit...if you must, connect GND first.

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

void loop() {
  // Some example procedures showing how to display to the pixels:
  colorWipe(strip.Color(255, 0, 0), 50); // Red
  colorWipe(strip.Color(0, 255, 0), 50); // Green
  colorWipe(strip.Color(0, 0, 255), 50); // Blue
  // Send a theater pixel chase in...
  theaterChase(strip.Color(127, 127, 127), 50); // White
  theaterChase(strip.Color(127,   0,   0), 50); // Red
  theaterChase(strip.Color(  0,   0, 127), 50); // Blue

  rainbow(20);
  rainbowCycle(20);
  theaterChaseRainbow(50);
}

// Fill the dots one after the other with a color
void colorWipe(uint32_t c, uint8_t wait) {
  for(uint16_t i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, c);
      strip.show();
      delay(wait);
  }
}

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

  for(j=0; j<256; j++) {
    for(i=0; i<strip.numPixels(); i++) {
      strip.setPixelColor(i, Wheel((i+j) & 255));
    }
    strip.show();
    delay(wait);
  }
}

// Slightly different, this makes the rainbow equally distributed throughout
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);
  }
}

//Theatre-style crawling lights.
void theaterChase(uint32_t c, uint8_t wait) {
  for (int j=0; j<10; j++) {  //do 10 cycles of chasing
    for (int q=0; q < 3; q++) {
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, c);    //turn every third pixel on
      }
      strip.show();
     
      delay(wait);
     
      for (int i=0; i < strip.numPixels(); i=i+3) {
        strip.setPixelColor(i+q, 0);        //turn every third pixel off
      }
    }
  }
}

//Theatre-style crawling lights with rainbow effect
void theaterChaseRainbow(uint8_t wait) {
  for (int j=0; j < 256; j++) {     // cycle all 256 colors in the wheel
    for (int q=0; q < 3; q++) {
        for (int i=0; i < strip.numPixels(); i=i+3) {
          strip.setPixelColor(i+q, Wheel( (i+j) % 255));    //turn every third pixel on
        }
        strip.show();
       
        delay(wait);
       
        for (int i=0; i < strip.numPixels(); i=i+3) {
          strip.setPixelColor(i+q, 0);        //turn every third pixel off
        }
    }
  }
}

// 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);
  } else if(WheelPos < 170) {
    WheelPos -= 85;
   return strip.Color(0, WheelPos * 3, 255 - WheelPos * 3);
  } else {
   WheelPos -= 170;
   return strip.Color(WheelPos * 3, 255 - WheelPos * 3, 0);
  }
}
Neopixel Controller Test Script
Change the dataPin and pixels variables in lines 5 and 6 to fit your project. Much thanks to AdaFruit for the NeoPixel library and example sketches from which this sketch was mostly derived.

Schematics

Neopixel Controller
Micro-Controller and Power Distribution for 1 to Many Neopixels
Whimsyneopixelnano bb

Comments

Similar projects you might like

NeoPixel LEDs: Arduino Basics

by Alex Glow

  • 43,234 views
  • 1 comment
  • 46 respects

Clock Arduino Nano NeoPixel Ring Alarm/Timer Function

Project in progress by WannaDuino

  • 9,365 views
  • 18 comments
  • 38 respects

VU Meter on Steroids: Arduino Nano and NeoPixel WS2812B

Project in progress by Team WannaDuino

  • 21,875 views
  • 84 comments
  • 81 respects

Arduino NeoPixel Wifi

Project showcase by Andres Santos

  • 4,537 views
  • 0 comments
  • 12 respects

Arduino Clock with Neopixel Ring Animation

Project tutorial by Alexander

  • 42,079 views
  • 39 comments
  • 64 respects

Neopixel LED EyeBall

Project tutorial by HomeMadeGarbage

  • 5,400 views
  • 22 comments
  • 21 respects
Add projectSign up / Login