To be honest, I’m completely surprised I finished this project. Creating this LED cube has been by far the most time intensive Arduino project I’ve done, and I almost gave up on it. On my last post, I left off on finishing the LED Cube itself. Before I dive into the details of how I finished this nightmare, here is the finished product:

Making the Perf Board Work

The issue I ran into after constructing the LED cube was that fitting the individual LED pins into the Perf Board was next to impossible. The minute I managed to align one pin with the board, two more would pop out. After wrestling with the board for about an hour I took a break from the project. When I came back I decided to just begin soldering the legs in one at a time, bending the legs as I went. It took quite a bit of time and effort, but I eventually got to the point where all the legs were soldered into the board.

Wiring the Cube to the Arduino

The next step in the project was wiring the bottom of the perf board to the Arduino. To begin, I soldered 4 100 Ohm resistors to the pins representing the four layers of the cube.

After the resistors were installed. I soldered a wire to each LED pin representing a single point in the cube. Each wire requires a header pin to be soldered its’s end in order for fit into Arduino Uno board. Afterwards, I got something looking like this:

Mapping Points on Cube to Pins

Once you reach this point, the remainder of the project is smooth sailing. Simply plug in the headers and pull out a sheet of paper. Essentially, each cube can be thought of as a 3-dimensional coordinate system. Like so, I assigned an X, Y, and Z value to each LED. After I assigned a coordinate system, I mapped out the Arduino pins to each LED using pen and paper. Once I was able to map the points out, I listed the LEDs in order based on the pin on the Arduino Board itself. My particular layout started on pin 14 (1,1) and ended on pin 13 (4,4). It’s important to note that I didn’t map out the Zed axis as it remains independent in the code.

Code

The good news about the code is that once you understand the basics, programming complex patterns is relatively simple. In order to keep this post short, I’m only going to explain my setup method, loop method, and individual cycle method.

Setup Method

The setup method is extremely straighforward. Simple instantiate two arrays: one representing the columns (based on how your XY coordinates map to the Arduino Pins) and one representing the layers (Z). In the setup method, simply loop through the two arrays and set each pin to OUTPUT using the pinMode method.

Loop Method

Inside of the loop method, I call the various different patterns I programmed into the cube. You can review each of these methods in the download, but for now, I will only be covering one.

Individual LED Cycle Method

The cycleIndividually() method is the backbone of all of my custom patterns. The method does exactly what it sounds like. It simply cycles through each LED starting at (1,1) and ending at (4,4). Once the program hits the LED at (4,4), it restarts at (1,1) on the next layer. To turn on an individual LED you first must set all of the layers to low. Afterward, you select which layer of the cube (Zed Axis) you would like to light up and set it to high using digitalWrite(). Next, set the LED in your columns array to LOW. Setting it to low is counterintuitive, but is necessary to minimize the number of wires used in the project.

Download

Download the project files here.