A while ago, I wanted to start a project that would involve basic electrical engineering and circuitry, as I had no knowledge and very little experience in it, but wanted to be able to do some cool things with circuits later on. After looking through the internet for ideas, I settled on building a LED cube that displays programmed light patterns in a three-dimensional space.
Although being my first project involving circuitry and electrical engineering, I created the project from scratch after doing quite a bit of research on the topic. I decided to do a 5x5x5 LED cube (totalling 125 LEDs) and use a Teensy LC as the microcontroller. The LED cube is programmed with different patterns, and has a button to switch between the patterns.
Below is a video of the LED cube running a few programmed patterns. The spoiler box under the video describes each pattern shown in the video.
randomly turn on all, randomly turn off all
bounce planes between borders
shows rain pattern
(cut from video)
sends voxels between edges
shoots firework pattern
creates a stream of voxels travelling down the cube
spins voxels around border
I had to do a lot of research for this project since I had never done anything like it before. After examining many different constructions on the internet, I made my design to use SN74HC595 shift registers to be able to control all of the LEDs using only a handful of pins.
The LED cube uses persistence of vision and an LED matrix to display each pattern. The cube only controls one level (25 LEDs) at a time, turning each level on and setting them according to the pattern. Each level is cycled very quickly, so fast that our eyes can't see the levels turning on and off, and instead see it as if the entire cube is on at once. In the video, each level switches every 2 ms, or 500 times/sec, which makes it look constantly on. The LEDs are set up in a matrix so we don't have to use one pin for every LED.
The parts list of what I used and where I got each part from can be downloaded here. I had some materials already at home, so I didn't purchase everything on the list. For wiring, I stripped down some Cat 5 cables and used the wires inside. This project cost me about $45 total.
Here is the schematic, created with EasyEDA Designer. I'm not really sure how to organize a schematic, so it's a bit of a mess.
The Teensy uses pins
13 for controlling each level of the cube at a time (25 LEDs), while pins
0-4 are used to set each level on/off.
20 are status LEDs showing what pattern is currently displayed.
23 is for receiving input from a button to switch to the next pattern.
Shift registers are able to take in serial input and turn it into parallel output, which is how I controlled 25 LEDs at a time with only 3 pins.
DS from pin
11, and a clock
SH/CP from pin
13, the shift register will output the bit values on
Q0-Q7 after the latch
ST/CP from pin
12 is set.
The overflow pin,
Q7/2, is fed into the input pin
DS of the next shift register, creating a chain.
The LED cube part of this project took longer than I had expected it to. Building the LED Cube took a little over a week, and each level took a few hours each day to finish, although it didn't feel like it. I had to wrap copper around the cross-rods on each level, as the rods weren't being held well with the solder. The cube ended up not as straight as I had hoped, but I was still pleased with the result.
The LED cube is 6 in x 6 in x 6 in (15.24 cm x 15.24 cm x 15.24 cm), with a 1.5 in (3.81 cm) space between each LED.
The circuit was slow work, where I had to make sure each wire I soldered in was in the right place and there weren't any shorts anywhere. The wiring ended up being a lot messier than intended. I didn't leave a lot of room for putting in the ICs in the sockets, which was annoying to pop in.
The only real issue I had was that I couldn't figure out why the cube didn't display the right pattern, until I realized that I had forgotten to solder the CLOCK wire to the Teensy. It's a good thing I didn't run into any circuitry problems because I don't think I would've been able to diagnose the problem.
To control the LED cube, I wrote a general library for Arduino microcontrollers to write pattern data to the shift registers. I actually wrote the library before building the LED cube, and used a terminal for testing the pattern output. It was first written in C, and later ported to C++ around 5 months later.
The library is able to display frames and create animations from changing the LEDs (voxels) powered state. It can manipulate the cube by frames per voxel, column, or plane. It has some built-in patterns, as shown in the video above. The library also has the feature to display text and characters to create messages.
A more in-depth description and documentation of the library can be found here.
Some library configuration is determined at the preprocessor level by defined macros and their values.
Preprocessor directives can be easily placed at the top of
Pin numbers can be changed in
To change these values, the library must be recompiled.
This can be done by running
make on the library's root directory.
Note that Arduino actually requires the source code files for its libraries and not the compiled versions to run.
To create a zip file of the changed library, run
The library can be easily installed on Linux machines by using
make install, which takes the zipped library in the current directory and puts it in
The library, documentation, and examples can be found here on GitHub.