Google+ Facebook Twitter Pin It Reddit

Jamce Build

Charlieplexing: RGB LED CUBE

By Adubinsk

RGB LED Cube Description: RGB LED Cube Kit
Skill Level: Advanced
Assembly Time: 10 hours

This DIY Electronics Project might be the simplest design of tri-color LED cubes out there. Without using complicated components such as shift registers, decade counters, reference shifting transistors or any other components to control LEDs, this project focuses on a much simpler, cost effective design. This LED cube utilizes Charlieplexing and can operate using only 16 digital pins of an Arduino controller with no additional hardware besides the RGB LEDs themselves.

You will need:
Solid hook-up wire
Soldering iron and solder
Wire cutters

Kit Includes:

(2) Header Vertical Receptacle 1 Row 16 Count
(4) Male to Male Standoffs 3-16"
(10) 4-40 Zinc Plated Steel Nut
(1) 4.3" x 6.8" General Purpose Prototyping Board
(1) USB-A Male to USB-Mini 5-Pin 2.0 Cable
(1) Arduino Nano 3.0
(64) 5mm Water Clear GRB LED
(1) Instructions

Click here to order RGB LEDs Cube Kit

Charlieplexing is driving many LEDs with only a few pins of microcontroller. This can be useful when needing to display a fancy dot matrix without many other components.

Assembling the Columns

The LEDs come with a clear lens, however it needs to be diffused to widen the viewing angle. Begin by hand sanding the entire area of each LEDs plastic dome with 200 grit sandpaper.

Once all the LEDs are diffused, take all four of the leads and bend them out in 90° to each other, according to the following diagram (below) the black pin represents the cathode. Also, note that the flat spot on the base of the LED is nearest to the red pin and you should hold each LED in the same orientation with the flat spot pointing up, like in the diagram. Be sure to bend the leads the same way for each LED so it is easier to put together later.

Diffusing the LED
Diffusing the LED


Bending the Pins
Bending the Pins
Mark the ground pin
Mark the ground pin


Use a black felt marker to mark the ground pin. Include a testing procedure to check if all the colors work in the LEDs. This is easier when the leads are spread apart. Use a 9V battery in series with a 330Ω resistor, by taping one end of the resistor to the positive(+) terminal and keeping the ground leg of the LED on the negative(-) terminal. Gently touch each leg with the resistor while keeping the ground leg of the LED touching the (-). Red should appear brightest and blue the dimmest. It is possible to use a larger resistor than 330, but not lower. Using too low of a resistance value may blow one or more colors inside the LED. Using too high of a resistor might make certain colors hard to see.

In each column, the LEDs will be all rotated 90° from each other. So keep track of which way the leads are rotated. If you have lost track of which rotation you are on, reference the marked leg of the LED. The blue leg in the image represents ground. Notice each LED’s flat spot is turned 90° relative to its neighbor.

Testing the LED
Testing the LED
Lining up the LEDs
Lining up the LEDs


The legs are bent to look like a pitchfork. The PCB board is used as the jig where the LEDs are placed to create the straightest columns possible. The bent legs are spaced an even 3 holes apart from each other, where each LED is spaced 12 holes away from each other. Use pliers to grip the legs up to the base and bend the legs. It just so happened that the pliers used for this demonstration were 3 holes apart. The spacing isn't so important. These distances are recommended, but can be changed to meet your own wants. In addition, you can use 10 pieces of masking tape level the bulbs with the board. Refer to this figure to see how each LED is aligned in the column.

Caution: Do not let the iron touch the LED for more than a couple of seconds. Heat can damage LEDs. Cut some wire about 4.5" to 5" long and strip the insulation to make straight wire. You can pull on the wire with pliers in each hand or use a vice grip and one set of pliers to straighten the wire.

Placing LED in a jig
Placing LED in a jig
Wire tighten in a vice
Wire tighten in a vice


While keeping the LEDs in place, lay a straight wire across one side of the column. Solder it to the legs of the LEDs and repeat for the other side.

Laying the first support
Laying the first support
Laying the second support
Laying the second support


Flip the board to its back side and push the column out of the jig. Use two hands when pushing to keep it from bending.

Taking the column out of the jig
Taking the column out of the jig

Lay the column on one side. Use a free hand to lay a straight piece of wire across the middle legs of the column. Solder the wire into place.

Laying the third support
Laying the third support
Laying the third support
Laying the third support


Solder a piece of wire to the last side of the column. Repeat for the other 15 columns.

Here's how the column should look like after soldering all 4 pieces of straight wire to the legs. Do not cut the legs or any excess wire at this point. Each column will need to be tested to ensure proper functionality after soldering. While in the photo it looks like only 2 straight wires were soldered, really there are 4.

One column with all the trimmings in place
One column with all the trimmings in place


Testing the Columns
Test the columns to make sure LEDs weren’t damaged in the soldering process. Included is a test sketch and a hookup diagram. Wire the legs of the column to the corresponding pins of the Arduino. Assemble each column into breadboard one at a time, run the legs to the Arduino via wires, then run the sketch by copying or opening it up in the Arduino IDE.

Testing the LED Columns
Here’s some code to test all the LEDs in a column after soldering. It will start at the bottom-most LED and cycle through possible colors moving up to the next LED. Make sure to align the column specified by the image to test brightness and LED orientation. Wear sunglasses when running software! While the code will not damage the LEDs, staring at the LEDs for an extended amount of time will damage your sight.

Disclaimer on Light Bleeding
When testing an individual column, don't worry about other LEDs bleeding colors. Also note that there is no actual ground, but just a potential difference, or voltage drop, across the different pins. Each pin is "on" but when tested with a multimeter notice how each pin combination is set to a different voltage resulting in different amounts of current moving through the pins at all times. "Ground" is set to a lower potential than all the rest, so that's why we see some light bleeding because the voltage difference across the same pin combination for a different LED might be enough for it to dimly turn on. There is no real ground, but only higher and lower potentials across different pins resulting in different colors turning on at different intensities.

Analogy
Imagine as if there are 4 different waterfalls rushing water at different heights. The highest waterfall will achieve the fastest water falling, assuming a common source. The fastest water is the strongest and will therefore turn the water wheel located at the bottom. The other weaker waterfalls will still fall on their water wheels, but will offer a lesser strength to turn them, resulting in slow moving wheels with respect to the fastest one. They are still turning, but slowly. The same case is in our LED project except water speed is current, height is voltage, and the wheel is the color that turns on. A higher potential, or voltage, will look the brightest.

For example:
  • Pin combination 1-2 (Red): Voltage = 0.8V
  • Pin combination 1-3 (Blue): Voltage = 1.2V
  • Pin combination 1-4 (Green): Voltage = 2.2V
Combination 1-4 receives the most amount of current passing through it, because it has the highest potential difference between the pins (2.2V), resulting in the color green to turn on!

Other current may leak into another LED because the potential difference is high enough to pass some current to notice a visual effect. Other LEDs in the column get this same current, but not to the same level, that is why one LED is the brightest, one is dim, and the others can hardly be seen. Not enough current passes to these LEDs to notice the same visual intensity.

Building the Cube
Trim the excess legs off of the columns to get a clean look.

Trimming excess wire
Trimming excess wire
Direction is important when placing columns
Direction is important when placing columns


Time to strategically fit the columns into the PCB! It is very important to keep them all aligned in the same direction, so to make wiring as easy as possible. Begin by fitting one column into a corner of the board. Confirm the proper height you would like the column to stand and solder the legs into place.

Corners all go in the same direction
Corners all go in the same direction


Start with the corners and then place the columns row by row. In this example, each column is spaced out 12 holes away from each other. Orient the flat spots of the bottom most LED in the same direction. After the corners have been filled it becomes easier to solder the rest of the columns with the help from a jig. This one is made from cardboard, spacing holes out 1.125" apart. The holes are big enough for the tops of the LEDs to fit through and touch through the other side.

The idea is to fit the columns into the PCB first, flip over the board with all of the columns in, and solder them all at once from the other side. Before placing the other columns in, focus on making the PCB sit level with the surface .The corner columns should be soldered in first to level the board for the other columns to sit. Begin by soldering one leg of each column to board at the height you want. Once the board is flipped over, loosen some solder and hand adjust each column to fit into the holes. Once you are happy with the position of each column, solder the legs into place.

Here's what the board should look like when all of the columns are at their proper height and fit into their holes.

Soldering all the columns at once
Soldering all the columns at once


All of the columns should face the same direction. This would be a good point to check to see if in fact they are. Use the "flat spot" of the bottom-most LED to check each column.

Close-up of columns facing same direction
Close-up of columns facing same direction


Finished looking product, without the Arduino. Note the columns in the figure aren't to scale with the board.

Flip the board over to attach the wires. The easiest way to wire the board is in four groups of four. Red arrows indicate where the columns were pointing on the top side.

16 columns
16 columns
Flip the board and mark the front
Flip the board and mark the front

The first and second groups are fairly simple. The third group is a little tricky and the fourth group is the hardest.

Group 1
Group 1
Group 2
Group 2


Group 3
Group 3
Group 4
Group 4


Connect those 16 wires to the pins on the Arduino. A table for wiring is included below (Table 1). The Arduino is fitted into headers so not to permanently fix it into the PCB. Solder the wires to the respective pins of the headers. Screw the standoffs to the board. Use a mini USB cable for power.

Finished product
Finished product

Wiring reference chart
Wiring reference chart

Testing the Cube
Once the cube is all wired up to the Arduino and you would like to make sure the LEDs all still light up, run this simple test. Just upload this piece of code to the Arduino and watch different colors cycle through the columns. You should see all the different columns light up in order.

The libraries developed by Asher Glick for the Charlie cube provide you with a nice set of functions that you can use to draw animations. Click on the hyperlink provided, and download the 5 files provided. Make sure they all sit in the same directory/folder before compiling. You might need to manually include the header files (.h) to the IDE, if compiling doesn't work right away. In addition to Asher's code, Jules Meredith has uploaded more patterns based on Asher's build and code.

Reference chart

Click here for selection of programming programs.
Photos and links credited to Asher Glicks http://aglick.com/charliecube.html.