Introduction: LED Cube Code Generator 4X4X4 RGB

Picture of LED Cube Code Generator 4X4X4 RGB

For anyone running a 4X4X4 RGB LED cube running on 3 TLC5940s and 4 P-Channel MOSFETs, such as Great Scott's Lab or Emiliano Valenca's cubes they have shared with us here on Instructables.

I've built a little code generator to assist in making patterns for your cube. It works for a single pattern, but have not yet figured out a good way to load multiple patterns to the Arduino and have them loop through them. If you have any suggestions, put it in the comments below and I'll update this Instructable.

http://codepen.io/BoucherM/full/PPjGdQ/

The layout is from looking at it from the top, so "0" would be the LED on the corner, for all 4 layers.

The code it builds links to arrays that you must first create in your sketches. Create 3 arrays, one for each color, and a fourth array for the 4 layers (whichever pins are turning on the MOSFETs).

The color arrays are called "rTlc" for the red LEDs, "gTlc" for the green LEDs, and "bTlc" for the blue LEDs. The array is built with the address associated with the TLC, and our code we create accesses this address by selecting that element in the array. When building the arrays, just match the location of the LED on the generator to whichever output address of the TLC turns that LED on. So selecting the red LED "4" on the generator would access the 4th position of the rTlc array, and the output of the generator would be "Tlc.

Pretty much the same thing for the array selecting the proper MOSFET to switch on certain layers. The array name is "layerPin". The array will have four values in it, whichever pins drive on the MOSFETs. The output code will set the output pin low to switch on the MOSFET, or high to switch the MOSFET off.

Just copy the output code in your loop for the Arduino. The small delay I added to the code between turning the layers on and off helped greatly to get rid of ghosting of the LEDs.

Comments

seamster (author)2015-10-15

Awesome, thank you for sharing this!

About This Instructable

1,472views

5favorites

License:

More by BoucherM:LED Cube Code Generator 4X4X4 RGB
Add instructable to: