This is the forth cube project I have posted here. I said in the third one that it would be the last, but this cube is a whole new way to build cubes - much easier, using LEDs very similar to the programmable LEDs that Adifruit's Neo-Pixel strips and panels use. This approach makes an LED cube that is multi-color, very bright, easy to construct and easy to program.
Hardware OverviewUsually we have external shift registers to provide the huge number of digital pins necessary to control a cube. My first three cube projects eliminated the shift registers by using the large number of digital output pins on the MEGA. But this cube is totally different. All the LEDs in this cube are wired up in a long single strand, like an LED strip, and a single digital pin on an UNO controls the whole thing. There is literally nothing to the project except an UNO, 125 programmable LEDs, and a power supply.
Let's take a look at how this cube is built. It uses the APA-106 programmable LED. This 4 lead device contains an internal control IC which controls the brightness of the red, green and blue LEDs it contains, but also has a built in shift register, capable of recognizing the data sent to it, but also passing on the data not meant for it to other LEDs in the chain. We must provide +5 volt and ground to each LED, as well as a single data line that will run through all LEDs in the chain. Our cube is a single chain of 125 LEDs.
The APA-106 LEDs cost 20 cents each on EBAY and currently have to ship from China. So you need $25 worth of LEDs and it takes 3 weeks to get them. Regular RGB LEDs cost about 9 cents, so this approach is a little more expensive, but much, much less work!
Let's look at some basic details of construction. The really nice thing about this cube is that it is build layer by layer. This means we can put it together in a simple jig, wiring together 25 LEDs at a time, on a mostly flat plane. This means both easy construction and a nicer looking cube, compared with regular cubes that are built in vertical panels.
Here is what a single layer of the cube looks like:
There are a couple of things to notice about the diagram above. The data line in blue snakes back and forth, so that the LEDs in rows 1 and 3 go in the opposite direction from the LEDs in rows 0, 2, and 4. They have a different lead form as a result of that, as I always keep the Ground rail at the top and the +5 rail at the bottom.
Also note that the data out at the end of the layer is now on the opposite corner of the cube. So when the data line goes up to the next layer, it causes the next layer to be 180 degrees turned around compared with the layers above and below it. That's not a problem - we will fix it in software. So the cube looks like this:
But there is one final twist to the diagram above. Note that the Ground rail goes along one side of the cube and the +5 volt rail along the other side. That actually means that layers 1 and 3, which are rotated 180 degrees, need their Ground and 5 volt collection rails reversed from what it shows in the layer diagram above. (The statement above is in bold because I forgot that initially and built all 5 layers the same. It took a while to repair.)
SoftwareAs we said earlier, this cube is controlled by a single pin (digital pin 6) on an UNO. We are using Adafruit's neo-pixel and neo-matrix libraries to help with the programming. The two combined libraries are intended for use with Adafruit panels made with a very similar kind of LED. The neo-matrix library in particular helps because it already understands the back and forth path of the data line. We simply tell it we have 5 different 5x5 panels all chained together and it does all the rest, allowing us to address LEDs in a layer by their X and Y coordinates. The only thing we have to deal with explicitly in software is the fact that layers 1 and 3 are turned around 180 degrees. It turns out that is a simple fix, and we can easily create a function/subroutine that specifies the color of a single LED with an LED(x, y, z, color); statement.
The neo-pixel library provides a great set of tools to control the colors you can create with these LEDs. I chose instead to use a relatively simple color scheme that I used on my previous RGB cube. It gives you a rainbow color pallete with 42 colors, along with white (all 3 LEDs on) and black (all 3 LEDs off). While not as versatile as neo-pixel's color pallete, it allowed me to just drop in many of the animations I had previously created for the original RGB cube.
The show that is included in the attached Arduino sketch is 13 different animations that take about 3 minutes before repeating. They fill the UNO's program memory. However, for those willing to experiment, there are many additional animations in my original RGB cube's MEGA program that will work unmodified with this cube.
There is one more thing we should cover in software. LED cubes normally have to be refreshed every few milliseconds. That's because we only turn on one layer at a time. By lighting each layer many times per second, we create the illusion that they are on all the time. None of that is true for this cube. All LEDs are on all the time until you turn them off. So no refresh is required. I have a refresh routine in my software, but it really is optional. Every 15 milliseconds, it sends out a single command: cube.show(); This causes the neo-pixel library to transmit to the cube any changes you have made since the last cube.show(); It saves me from putting a lot of cube.show();s in my code, but is otherwise unnecessary. And because the LEDs in this cube are on all the time, it is much brighter than regular LED cubes. A single command controls the brightness. These LEDs are so bright, that I am running all the software for it with brightness set at 10%. If you set it any higher than that, your cube is blinding!.
Construction DetailIn this next section, I am giving you some pictures and details about how to construct this cube. It is much, much easier than a cube built with regular LEDs, but there are some details that you must be careful with. We will start with lead forming.
The picture above shows how I formed the leads. The ground lead, which is the longest, is the one bent up. It is only bent up to help see that it is the ground lead. It's hard to tell which it is if they are all bent flat. The lead form on the left is for rows 0, 2, and 4. The one on the right is for rows 1 and 3. So for each layer, we bend 15 LEDs like the left image and 10 like the right image. The difference is a result of the direction of the data path.
You can use any piece of wood you have around as long as it's at least 6 inches square. The holes are 29 mm apart ( approx. 1-1/8 in.) in both directions. This size was dictated by the length of one data out lead and one data in lead, leaving about 1 or 2 mm overlap where they are soldered together. You might verify all this with your own LEDs and adjust that spacing slightly if your leads are a different length. I wanted the LEDs as far apart as possible, so that they don't cover each other up in the cube, but very small overlap of the leads means you need to be careful with the hole spacing. I laid out the grid very carefully, used a punch to carefully position the holes, then used a power hand drill to drill the holes, and the result was not good enough. If you have access to a drill press, use it. Small errors resulted in a couple of places where the data leads didn't quite reach each other. You can see these places in the picture above, because I had to enlarge the hole and put a little reusable adhesive in it to get the position right. The LEDs are 8 mm across, so the holes need to be 8mm also. I drilled them all the way through my 1/2 inch piece of wood.
Next we place LEDs in all these holes, again 15 with one lead form and 10 with the other. The leads looked nicely formed until you looked at them in the jig. They needed some tweaking to get the data leads to line up. These LEDs are heat sensitive and can be damaged by soldering near the body, so I used clip on heat sinks everywhere when soldering them.
In the picture above, we have connected the data lines and ground lines. We still need to connect the +5 volt leads to a rail. You can clearly see the different lead forms and that the data direction on rows 0, 2, and 4 are left to right, while on rows 1 and 3, it is right to left. Note that now that the ground rail is installed, we can cut off the part of the ground lead that we bent upward to identify it.
The power rails are 22 gauge tinned copper. It can be straightened before using by one of two methods. Clamping one end in a vise and giving it a good pull gives you a straight wire that works fine. If you put other end of the wire in an electric drill, and turn it many times while pulling on it, it both straightens and becomes very rigid.
The image above shows a finished layer. There is a lot of details to discuss here. In addition to running our +5 rail along the bottom of each row, we have attached heavier 18 gauge rails along the side. In this picture, the big Ground rail is on the left and the big +5 rail is on the right. This is what you will do for layers 0, 2, and 4. Important: For layers 1 and 3, you need to put the big Ground rail on the right and the big +5 rail on the left, as these two layers are turned 180 degrees from the others! Finally, we have now connected the data lines between rows. This is the one place we have to depart from everything being in a flat plane. These connections are made about 3-5 mm above the power rails, still using bare 22 gauge wire.
Above, I mentioned using heavier 18 gauge wire for the left and right rails. I also used 18 gauge for the vertical rails that hold the layers together. We will talk about that in a minute. The 18 gauge is optional. It's not necessary electrically - the 22 gauge can easily handle the current. I just used it to give the cube some added strength and rigidity. The 18 gauge wire can be straightened just like the 22 gauge wire, and it is very rigid after straightening with the drill method.
I was very disappointed by how crooked my wiring was when I finished the first layer. I thought this method of construction would produce this beautiful wiring. It didn't, but the LEDs themselves are very well positioned, and in spite of what you see here, the finished cube was by far the best looking cube I've ever built. The wires kind of fade into the background in the finished cube!
At this point, you can test a finished layer using the N555_layer_test sketch in the software I am supplying. Just connect the +5 V rail to +5 volt pin on the UNO, the ground rail to GND on the UNO, and the data in line to pin 6 on the UNO. Each LED quickly flashes RED Green Blue, in order along the data line. (I slowed it down in the supplied sketch - almost too fast to see in this video.)
When we have our five layers built, we can now begin the actual construction of the cube.
There is not much inside the box. The UNO was installed with a little hot glue. The important thing here is how we installed the 4 vertical rails that support our cube. You need to start by drilling 4 holes, each about 1/8 inch away from the inside corner of the base. They should be just big enough to put the vertical rails through. In one corner, you need to drill a second hole, about 1/4 inch father away from the corner. This hole is for the data line. Now get 4 pieces of 8 inch, 18 gauge straightened rail. Bend the last 2 inches 90 degrees and insert them through the holes in each corner, so that you have 6 inches sticking up vertically, and two inches up against the insides of the base. Attach and solder some wires to each rail. and then use a generous amount of hot glue to secure the rails to the inside of the base.
In the picture above you can see the yellow data line coming out of its hole to pin 6 on the UNO. The red and black wires coming into the base from a hole in the side of the base is our 5 volt power supply. The green wires are 5 volts. The black wires are ground. So the two vertical rails on the left are 5 volts and the two on the right are ground.
So now we go topside and start installing layers. At the bottom of the picture, the ground rail of layer 0 is attached to the two vertical ground rails. At the top, layer 0's +5 volt rail is attached to the two vertical +5 rails. In the lower right corner, the yellow wire is attached (out of view) to the data in pin of layer 0. At this point, as seen in this picture, I ran the N555_layer_test sketch again. (I hadn't installed the power supply at this point. That's why you see those alligator clips.)
We are now adding additional layers to our cube. Layers are 29 mm apart, just like the LEDs were within a layer. So you need four spacers each 29 mm high. Mine are shown in this picture as white plastic squares, but you could use 1/2 inch doweling or anything else you have around. My spacers didn't want to stay put, so I resorted to a small dab of reusable adhesive to keep them in place until I had soldered the new layer in place. I removed them immediately after soldering out of fear they would get stuck in there, but I never had any problem removing them.
The other thing we need to do with each new layer is connect the data in pin to the data out pin from the layer below. The photo above shows how this is accomplished. (It also shows that my layer rails didn't always align perfectly with the vertical rails, so some improvising had to be done.)
There is a second test sketch in the software called N555_layer_test2. You have to tell it which layer you want to test. It lights up the whole layer in Red. I suggest running this after installing each layer to make sure you have everything connected and no cold solder joints. It is much easier to fix a problem when its at the top of the cube than after you've put other layers on top of it.
When all 5 layers have been installed, you are done and ready to run the show - the N555_show sketch. If you want to install the optional acrylic case, you can do it now. It fits perfectly on the base and can be secured with a small amount of hot glue at each corner. I also used the base that comes with the acrylic case to close the bottom of my base. Again just a little hot glue fastened it, and it was also a perfect fit.
Everything above is exactly as I built my cube. However, I always learn stuff in the process of designing and building something. Here is an alternative way to construct this, one I would use myself if I were to build this again.
The diagram above is very similar to the first one I presented. However, it has some advantages, This one uses one lead form for all LEDs. I also gives us a 40% reduction (6 vs. 10 per layer) in the number of power rails running through the middle of the cube. If the LEDs are properly spaced, the power leads of the LEDs should just reach the power rails (assuming you don't bend the ground lead up to identify it, like I did). Even with this modified design, the big power rails on the left and right still need to be reversed for layers 1 and 3, as described in the construction details above.
Comments