Introduction: Led Star With Arduino and WS2811 Neopixels
This little project makes a great ornament to hang in your window at Christmas time. It is a 20" wide star with 50 "neopixel" leds around the perimeter. Each led is individually addressable and it is controlled by an arduino device which can be programmed to sequence the leds in various patterns.
Depending on where you live you may be able to get all or only a few of the items required so I will try to list out some sources at the end as well as links.
I have always loved to tinker and build things. I find myself in a position now where I have quite a bit of time on my hands so I resurrected an old hobby of mine, electronics. With the Christmas season fast approaching, I wanted to do a few cool things and what better way than lights, lights and more lights? I'm still at the beginning stages of learning about micro controllers and how to program them but incorporating the learning along with a project makes it quite enjoyable. I won't cover all the bases here regarding programming and general electronics but there's a wealth of knowledge available on the internet and its just a quick Google away. Have fun and let me know what you think.
Ok, on with the show.
Step 1: Materials and Tools
I'll provide some resources for sourcing some of these items later in the article
- Arduino Uno or other compatible micro controller ( I used the OSEPP Uno R3 but will switch over to a Pro Mini for the finished version). You can use the genuine Arduino but there are lots of other clones out there that are a lot cheaper
- RGB Led pixel string 5volt, prewired, 50 leds with ws2811 controller chip. Use waterproof string for outdoors
- Small prototyping breadboard (optional)
- 300-500 ohm resistor (330, 390 or 470 ohm are standard values)
- 1000uf 16v electrolytic capacitor (can be a higher voltage rating eg. 25V 35V 50V)
- 5 volt power source @ 2-3 amps (make sure it is at least 2 amps)
- Connector for the power plug
- jumper wires
- 20X30 posterboard with metallic film on one side (or any other medium that will support the leds)
- Xacto or Olfa knife, scissors, tape, pencil, ruler, tape measure, paper, straightedge drill and drill bits-3/16" and 7/16", small sharp punch
- If you want to make a permanent version then you will need a soldering iron and solder
Step 2: Building the Star - Cutting It Out
NOTE: You'll notice that with some of the dimensions, that the numbers don't add up exactly. This is because when the cad program inserted the measurements, it was set to display in 1/16" increments. If a measurement is say 5/64" it would display 1/16" instead. This minor amount won't be noticeable.
The first thing to do is layout the star. I added a radius to the tips of the star. This way I could fit a bigger star into a 20" X 20" square. The layout was done on the computer using Deltacad, a small easy to use cad program. You won't need to learn it for this project but you can download a demo copy which is good for 45 days. I'll include the cad files in this article so you can view them or print out the measurements.
I used an Elmers holographic foam board (20"X30") as the star. I suppose you could use anything that is stiff enough and not too thick but the foamboard is fairly easy to cut and work with. I got mine at Walmart but I'm sure it is available at lots of craft stores. Transfer the sizes to the foamboard (backside without the metallic foil), draw in the lines and then your ready to trim it to size. Make sure you draw it all out first and then check to see that it looks all symmetrical. It's easy to goof on a measurement. Remember the golden rule: measure twice, cut once. I used an Olfa knife to cut the board. Lay a straightedge along the lines you want to cut and then score the board. Be careful not to go all the way through on the first cut and make sure you have something underneath to protect the surface you are cutting on. You don't want to start carving up the new dining room table!! After you have scored all the lines, cut again a little deeper. The idea is to cut deep without going all the way through. Cutting all the way through can end up leaving a jagged edge on the foil. After the scores are deep enough, cut all the way through on the ends of each line. this way you can see the start and end of each line from the foil side. A smaller knife is handy here. Xacto makes a great little hobby knife. You can get them at Staples among other places. Now, you can switch over to the foil side and score through the foil from the top, which will help keep it from distorting. Be very careful to make sure you are cutting the right lines or it's back to the store for more foamboard. After the star is cut out, you can radius the tips with the knife and clean up the edges a little. Note: the drawing doesn't show the radius tips but that can be done easily by eye after it's cut out.
Step 3: Laying Out the Holes
The center of the holes run along a line 3/4" in from the outside and are spaced 1 3/8" apart. This gives a total of 50. Convenient because the pixel strings are available prewired in strings of 50. Layout the holes and then use a fine punch to push a small hole through the board (again, this is done from the back side. Now, drill a pilot hole about 3/16" or so all the way through. Then, from the front side, drill through again with a 7/16" bit. Do this carefully as you don't want to tear up the foil. The specs for the leds call for a 12mm (1/2") hole but because the foamboard is soft, a smaller hole tends to keep them tighter. Because it is foam, a type of plastic, drilling tends to heat up the material. This results in it melting somewhat. We are also dealing with the foil and glue that holds it on so in the end, you won't get a nice clean hole. I used the razor knife to clean them up a bit and get the larger loose bits off but by the time it's all done, you won't really notice the rough edges. I was thinking of sourcing out some kind of punch but in the interests of time and budget, I went with the drill. You can layout the holes with the measurements provided or if you get a copy of Deltacad and download the cad files, I'll include a full size layout of one point of the star. This can be set on the drawing and used as a template to punch through the hole location.
Step 4: Installing the Leds
If you haven't worked with these kind of leds before, be careful or your project won't work or will run in reverse. Make sure they are of the WS2811 variety and use 5 volts. They come prewired in strings of 25, 50, 100 or more. There is no standard for wiring order or color code so you will have to determine this yourself if there is no documentation with them. The pixels have a starting point and an ending point, often terminated with a small plug. Inside the pixel is a RGB led, a WS2811 integrated circuit and a resistor mounted to a small circuit board. If you look at the closeup photo, you can see the wiring at the top. There are 3 wires in and 3 out. On each side you should see where they attach to the board. One side is the input while the other is the output. On the kind used here the input pins are labeled GND (ground) DIN (data in) 5V (+5volts). Mark the backside of the star with TOP at the end of one of the points. This top hole will be #0. Then, going clockwise, number the holes (#0 to #49). Push the leds into the holes until they protrude out the front far enough that they will be seen. They have a small nub on each side that will help hold them in. You may have to clean up the holes a little. If any are too loose, you may have to use something to glue them into place such as silicone. A good idea is to try them in a sample hole. If you used the 20X30 foambard, there will be a 10" strip left over that you can drill some sample holes into. I had no problems with the leds being to loose. Unless you plan on using the led strip elsewhere, you can also snip off the end plug leaving some wire on both it and the strip. This way you can attach it to your controller circuit and then simply plug it into the led string.
Step 5: Wiring the Arduino and Leds
For this step, you will need the Arduino, resistor, capacitor, power source, wire. You have lots of options here. A small breadboard or a piece of perfboard makes wiring up the project easier. If the star is to be permanent, a small piece of perfboard with solder pads is ideal. For this project we will use a solderless breadboard so that modifications cam be easily made. Three pins are used on the Arduino, ground, 5volts and pin6. on the breadboard, mount the resistor and capacitor. A small led with current limiting resistor can also be be used but isn't required. It is handy though to indicate that power is present. If you decide to use the power led, make sure you use a current limiting resistor in series with it. As leds are polarized, you will have to connect the anode to positive and the cathode to negative. The resistor can go in either leg. I used a green led with 150 ohm resistor.
If you aren't familiar with breadboards, see the photo. It shows how the terminals are connected underneath. The power busses are connected horizontally all along each row and the middle connectors are attached in rows of 5.
Most breadboards have a power buss on each side. The power source is connected to one of these. Make sure that you observe polarity. If a wall adapter is being used and it has a plug on the output, a matching jack can be wired and attached to the breadboard otherwise you will have to strip the wires and insert them in to the board. If that is the case, again, make sure you observe the polarity. If the wires aren't marked for polarity, you will have to check with a multimeter for polarity. If it has a plug, usually the center is the positive terminal. Although the Arduino has a 5 volt output, it can't supply enough power to run the leds. A handy item for wiring up the power jack is to use an adapter that has a plug on one end and 2 terminals on the other that you can connect wires to. I have some on order but they hadn't arrived in time for me to use here (see picture).
A capacitor is used between positive and ground. This "buffers" against power surges. The capacitor basically acts as a shock absorber and protects the Arduino. The resistor goes between the Arduino data pin and the leds.
Referring to the picture, place the capacitor across the power buss lines making sure the +side of the capacitor goes to the +side of the buss and negative to negative. Place the resistor across 2 of the component area rows. The power led and its resistor can also be hooked up if you choose to use them. Run 2 jumper wires from the power buss to the Arduino, + to Vin and - to GND. Next, another jumper from pin 6 to one end of the resistor. The led string connections are: DI (data in) to the other end of the resistor, 5V to + and GND to -.
Note: This can be wired up point to point without using a breadboard but it's a lot harder to fix any mistakes that way. I suggest using the breadboad first for testing and then hardwire later once everything is running smoothly.
That's all there is to it. Double check all the connections and then move on to setting up the Arduino.
Step 6: Setting Up the Arduino
If you already have the arduino software installed on your computer and are familiar with using it to load the code, then it's just a matter of loading the example sketch and then running it (with one small exception - see below).
If on the other hand you haven't, you will need to download the arduino IDE and install it on your computer. It is available at the arduino website here. There are also tutorials on how to install and use it so I won't cover those here. Once that is up and running, you can download the associated code for this project and load it on to your arduino. Once that is done and you have modified the code as detailed below, it's just a matter of powering it up and watching the star dazzle you.
I haven't finished any sketches of my own for this project yet but am working on some so I will give you some links for code and libraries that you can use to get started.
2 libraries that are available for these type of leds (WS2811) that are out there are the Adafruit Neopixel Library and FastLED. They are both excellent and both have example sketches to get you going. I used the Adafruit "strandtest" example for the video shown in the first step.
Again, if you aren't familiar with coding etc. there are great tutorials on installing libraries and using them. Google away! It would take too long to explain it all here and it is all readily available.
From the Adafruit library, look for strandtestin the examples folder. This is the code you need to load for this project.
A few parameters have to be changed in order for it to work with the kind of leds that are being used.
Here is the code:
#define PIN 6
// 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(60, PIN, NEO_GRB + NEO_KHZ800); CHANGE THIS LINE TO:
Adafruit_NeoPixel strip = Adafruit_NeoPixel(50, PIN, NEO_RGB + NEO_KHZ800);
We changed 60 to 50. This is the number of pixels in our strip. We also changed the color order from
GRB (green, red, blue) to RGB (red, green, blue).
The rest of the code is fine.
So if you're all hooked up, all you need to do is plug it in and let it roll.
Step 7: Resources
Throughout this project I have referred to the Arduino. Arduino is a brand name but is commonly used to describe any device of its type. There are lots of clones out there and they are available worldwide. In this case I used the UNO variety but there are other types that will work as well. There's a ton of boards coming out of China these days. I'd say most are decent but I'm sure there is some garbage out there too.
If you go to Ebay and look around, you'll get a feel for which are which. Check the sellers reputation and compare prices. Use the filters when you search. I always filter for "free shipping" . Sometimes an item looks like a good deal until you factor in the shipping. All of a sudden, it gets really expensive. So far I have had pretty good luck on overseas goods. Shipping time varies but I have had items arrive within 10 days of ordering and some as long as a month so if you are in a hurry, you should order locally.
I got the led string from an ebay seller in China. It was an auction item and I got them for $13.50 US including shipping which is a pretty good deal. If you buy them outright, a good rule of thumb is maximum $.50 a pixel or $25 for a string of 50. Watch the auctions though and you can save a few dollars. If they are strings of 25, that's fine because you can hook up one string to the next.
Depending on where you are located, most of the materials can be sourced locally. Rather than making out a big long list of suppliers here, I'll let you go ahead and google them up.
There are also lots of resources for arduino projects out there and lots right here on Indestructables to help you learn the ins and outs.
If you want a copy of the Deltacad program, you can download the demo here.
Step 8: Final Thoughts
If you go ahead and build this project, let me know. I'd enjoy hearing about it. If you have any comments or suggestions, likewise. I am still a novice at programming so I'm afraid I won't be too much help there but if you have a question, ask away and if I can't answer it, maybe somebody else can.
Participated in the
First Time Author Challenge
Participated in the
Participated in the
Make it Glow!
1 Person Made This Project!
- paps1 made it!