Introduction: RGB 4x4x4 LED Cube
Love comes in all colors, shapes and sizes. What if you can have all the colors, packed in a perfect cube?
Well, at TECHNITES we love LEDs and here we tell you how to use a bunch of RGB LEDs to create the grooviest cube ever.
Step 1: Gather All That You Need
Well, the first humans were hunters and gatherers; scavenging the stuff that they needed to survive. To follow in their footsteps, it's time to gather components that we need.
What do you need?
- For structure:
- RGB LEDs x 64 (buffed LEDs are preferred; if not buff the LEDs using sandpaper to diffuse light)
- Single strand wire x 1 roll
- Insulation tape x 1 roll
- Soldering iron (preferably one with a thin tip) x 1
- Solder lead x 1 roll
- Drawing board/ cardboard x 1 (an old one as you would have to drill holes into this)
- A drill (for the Stark)/ a large nail and hammer (for the Thors and hulks)
- Cylindrical plastic/ cardboard tubes of diameter 5 cm.
- For the circuit:
- General purpose board x 1 large
- IC bases (16 pin) x 12 Berg strips
- 12 Volts 2 Ampere adapter
- 8 pin connectors
- Jumper wires x a bunch
- 25 uF Capacitor x 1
- 1k-ohm resistor x 10
- ICs and boards:
- TLC5916 x 10 (current sink 8 bit shift registers LED drivers from Texas Instruments (C))
- 74HC595 x 1 (8 bit source shift registers)
- 7805 x 2 (power supply use 2 in parallel to avoid heating up of source)
- 75933 x 5 (LDOs to supply enough current to the source)
- MSP40 FET Launchpad x 1 (to program the Controller)
- MSP430G2553 IC
- Software requirements:
- Code Composer Studio by Texas Instruments
- Tera Term or any other terminal emulator
- Phosphene codes (optional, to sync your cube to music and sink all your worries)
[please check our LED Wall instructable on how to use phosphene (github link for code: )]
Step 2: Structure of Cube
1) A RGB LED could be of two types, common cathode or common anode.
The LEDs used here are common anode LEDs, i.e. they have one anode and three cathodes, one for each colour. Test all LEDs before using them; it would take highest levels of precision and Jedi skills to replace a LED once the structure is completed. Hold the LED vertically such that all the legs face you and the common anode is the second leg from left. Bend the anode towards you such that the legs don't touch each other and the anode is now perpendicular to the other legs. (Imagine yourself lifting your leg to kick your friend) Slightly spread the other legs such that they look like a 4 legged spider with one leg raised. Repeat it for all 64 LEDs.
2) On the board, draw 4 parallel vertical lines spaced 5 cm (the legs of anode must be at least 6 cm)apart. Draw 4 parallel horizontal lines perpendicular to the vertical ones such that they form 16 intersecting points. Drill holes at each intersection such that the LED head fits exactly into the hole. A larger hole may cause unstable structure. In case the hole is smaller, while removing the LEDs later, it would cause trouble.
3) Imagine yourself at the beach sticking your head into the sand and lifting one leg straight up and the other leg forward such that the legs are perpendicular to each other. Place the LEDs the same way such that the tip of one anode just touches the start of the anode next to it. All LEDs must be placed in the same configuration; for example, RED cathode at far left, bent anode next to it such that the leg faces you, Green cathode next to it and the blue cathode at the far right.
4) Solder the joints where one anode touches the other. Now we have 4 parallel trains of 4 LEDs each joint at anodes.
5) Strip a single strand wire completely. Pull the wire taut by attaching it to one end and rolling a heavy weight on it uniformly. Keep the wire perpendicular to the 5 columns of LEDs such that it touches all anodes. Solder all joints. It is advisable to have 2 to 3 such wires at each layer for added stability to the structure at different places. For example, one wire between LEDs 1 and 2 and another wire between LEDs 3 and 4 would ensure balance. Another wire in the middle would prevent sagging. Now, we have one layer of LEDs with one common anode and 16x3 cathodes. Carefully remove the layer from the holes and set it aside.
6) Make 3 more layers such that all 64 LEDs are used.
7) Leave the last layer on the board in the holes. keep the cylindrical tubes on the layer parallelly at distances.
8) Lift another layer carefully and place on the layer on the board carefully such that the layer rests comfortably on the cylindrical tubes and is aligned perfectly with the layer below it. Perfect placement would ensure that all the cathodes touch the cathode above it exactly. Slightly bend the legs wherever misaligned. Take care to ensure no short circuits.
9) Solder all joints and slowly slide the tubes out.
10) Repeat procedure for the remaining layers.
11) Now, we have 48 cathodes sticking UP at us and 4 anodes (one per layer sticking OUT to us). Assign co-ordinates to each LED starting from (bottom layer, Row facing you and Left most column i.e. like the first octant of a 3D co-ordinate system starting at origin.) We have 48 cathodes, 16 of Red, 16 of green and 16 of blue. Let us assign points as 00R, 00G, 00B, 01R, ..., 33G, 33B. Connect 8 pin connectors to the end of cathodes serially in the following sequence: 00R, 01R, 02R, 03R, 10R, ...., 32R, 33R, 00G, 01G, ..., 33G, 00B, .... , 33B. Connect a 4 pin connector to the anode starting from the bottom most (0th) layer.
Step 3: Circuit
Solder circuit as shown in the schematic.
The functionality of each component is explained below:
- TLC5916: 6 eight channel Constant Current sink shift registers cascaded such that data is sent through three lines, SIN5916, SCLK5916, LATCH5916. The 48 outputs from the cathodes are sequentially connected to the output channels of the TLC5916 array.
- How to send data to TLC5916:
The MSB of the data is sent first. The SIN pin is set high or low depending on the MSB of the data. The SCLK pin is pulsed (Sent high and sent low). The data is then shifted left once such that the second most significant bit becomes the MSB. Once all bits are transferred, the LATCH pin is pulsed once to send the data from the hold register to the output register. The output is then displayed when the Output Enable pin (Active low pin) is set to 0 on the pins O0 to O7. An external resistor is connected between R_EXT pin and GND to set the current in the output channel. To cascade two TLCs, the SDO pin of the first TLC is connected to the SIN pin of the next TLC with the SCLK, LATCH and OE’ pins of both shorted.
- How to send data to TLC5916:
- 74HC595 and LDOs (75933): This is used to select the row and supply enough current so that the single source supplies enough current for 16 LEDs (x 3 cathodes each). 74HC595 works on the same principle as the TLC5916. The output channels of the 74HC595 are connected to the enable pins of the LDOs. When the channels go high, the LDOs source current.
- Overall, we need 6 data lines from the microcontroller; three for the source registers and three for the sink registers.
- The capacitor and resistors act as decouplers and current limiters respectively.
- The 7805 is the voltage regulator used to convert the 12 V power supply to 5 V regulated power supply.
Step 4: Code
Refer to the diagram above for the algorithm and appendix for the links to the codes.
The matrix specified is a 4x6 matrix. The 4 rows are for the four layers. The first two integers in the columns contain the 16 bit value for the 16 red channels. The next two contain data for green channels and subsequently for blue.
The matrix is processed on the PC and sent to the controller through UART (Serial communication).
The matrix to be sent to the controller comes as 24 byte data sent layer-wise. It could be simple patterns, random data or music processed data using Phosphene.
Step 5: Make Connections and Debug
- Make connections:
- The 48 cathodes are connected in sequence to the 48 output channels of TLC5916.
- The 4 anodes are connected to the outputs of the LDO.
- The +12V and GND from the adapter are connected to the Vin and GND of 7805.
- The SIN5916 is connected to the pin assigned (in the code) as SIN5916 in the controller.
- Similarly SCLK5916, LATCH5916, SIN595, SCLK595 and LATCH595 are connected.
Thomas Edison had to do over 1000 trials for the light bulb. This would hopefully work in lesser number of attempts.
Step 6: Gasp at Our Pics and Read Our Footnotes
Notes and tips:
- The size specified here could be expanded to 5x5x5 or 8x8x8 or 10x10x10 depending on the number of LEDs and your patience.
- The 74HC595 is redundant here as there are only 4 channels to select. However, for a larger number of LEDs it becomes necessary.
- For LEDs having a common cathode, use 1 TLC5916 and 6 74HC595s.