# 3x3x3 LED Cube with Arduino Lib

There are other Instructables about building LED cubes, this one is different for several reasons:

1. It's built with a low number of off-the-shelf components and hooks up directly to the Arduino.
2. A clear, easy to reproduce circuit diagram is provided with plenty of photos.
3. A unique approach is used for the software which makes programming the cube easier and more expressive.

Parts needed:

-   1 Perfboard
-   3 NPN Transistors (2N2222, 2N3904, BC547, etc.)
- 12 Resistors (~220 ohms and ~10k ohms)
- 13 Headers (male or female)
- 27 LEDs
- Wire

## Step 1: Prepare the LEDs

This step largely follows the LED Cube 4x4x4 but we'll be building a 3x3x3 cube instead. A cube of this size is about as big as it gets without introducing additional circuitry and complexity. We'll need a total of 27 LEDs that will be grouped into three sets of nine.

Each set of nine LEDs will share a common connection amongst their cathodes (negative leads). I'll refer to each of these sets as a "level". Each of the nine LEDs on a level is connected to the corresponding LED on the other two levels through their anodes (positive leads). These will be referred to as "columns". If that didn't make sense it will become self explanatory as we build the cube.

To start we'll use a drill to create a jig out of a small piece of scrap wood. The jig will hold the LEDs in place while we solder them. I decided to space the holes around 5/8 of an inch apart (~15 mm) but the exact distance isn't critical. The hole should have a tight fit around the LED since we don't want them to move around while soldering.

Once the jig is done we're going to bend the cathode of each LED in a 90 degree angle. The cathode is identifiable in three ways: 1) It's the shorter leg, 2) It's on the flat side of a round LED, 3) it's connected to the larger piece inside the LED. Make sure you bend the cathode in the same direction for all of the LEDs.

Now we're ready to begin soldering.
 1-40 of 227 Next »
stringstretcher9 months ago

In your README file you state you have recently introduced an online UI for programming these routines... any link? I still love mine.

gzip (author)  stringstretcher9 months ago
The link in the readme leads to another link. As you can see, the UI is based on your Instructable and is modified to work with this cube. :)
https://rawgit.com/gzip/arduino-ledcube/master/ui/index.html
9 months ago

Got it! Thanks! Great job programming this. I showed mine today at a gathering of librarians who are interested in Arduino projects. Always gets a "wow!"

1e1e1928 days ago

Can somebody tell me which pin i have to connect with which pin on the arduino

cybermanrobot2 months ago

Great tutorial.

For the "Lights Out" function, has anyone experienced the following symptoms?

+ Constant flicker when the LED is on.

+ Only 3/4 of the LED go off before the function resets back to a full cube.

If so, any thoughts on the the cause and/or tweaks to fix?

Thanks.

Arduino IDE v.1.6.5; Windows 8.1, Mini Pro 5V; Experience: White Belt :)

osama.negm.354 months ago

How can I solve this Error:

ledcube.pde: In function 'void loop()':
ledcube.pde:49:57: error: taking address of temporary array
ledcube.pde:50:57: error: taking address of temporary array
ledcube.pde:51:57: error: taking address of temporary array
ledcube.pde:52:57: error: taking address of temporary array
ledcube.pde:53:57: error: taking address of temporary array
ledcube.pde:54:57: error: taking address of temporary array
ledcube.pde:55:57: error: taking address of temporary array
ledcube.pde:56:57: error: taking address of temporary array
Error compiling.

I used an Arduino pro mini. The acrylic case is the package from an HDMX speaker.
sajoldas5 months ago

my upper two lavel is not so much light. and down level number nine led is not so much light.

NolanH26 months ago

I downloaded your code and library. I enjoyed the soldering but these errors come up when I compile the example given:

ledcube:15: error: 'LedCube' does not name a type
ledcube.pde: In function 'void loop()':
ledcube:49: error: 'cubeFrame' was not declared in this scope
ledcube:49: error: 'f' was not declared in this scope
ledcube:49: error: expected primary-expression before ']' token
ledcube:49: error: expected primary-expression before '{' token
ledcube:49: error: expected `;' before '{' token
ledcube:196: error: expected `}' at end of input

6 months ago

Nevermind! I found that the library had an invalid name, just a simple matter of renaming it. Perhaps its my version of the IDE or the Windows 8 it runs on.

5 months ago

Hi,there could please give the answer step by step as i am really new to this . Would appriciate the help.

jackjackboom3 years ago
What is the color code on the 220 ohm resistors? I'm short on cash and am trying to harvest a couple from any electronics I can find.
6 months ago

also it is Red Red Brown

gold is +- 5%

6 months ago

that's my erreur :( help pleaz

fforoni1 year ago
I did it! It took me about 5 hours to build everything (more some extra hours to buy the NPN transistors that I missed).

Instead of green diffused LEDs I used non-diffused red ones and I think that diffused LEDs is the way to go. Instead of spacing 15mm I spaced 25mm and made it bigger than yours.

My next project is a 4x4x4 LED Cube using 3mm diffused LEDs. Maybe i'll post a step-by-step here on Instructables.
7 months ago

Please do! I understand that bigger is much harder, even by 1 in each direction.

eshan.wells7 months ago

So when exporting the code, which option do i choose? Height depth width, or depth height width?

I intend on making this, and i look forward to seeing the end result!

Thanks for the very explanatory instructable. I recently build it (very poorly (despite the good explanations)), and it works great. But when all the LEDs were lid, i thought it looked very flickering - i also thought it would be impossible to notice the latches at all - so i took a high speed picture of the cube, and discovered that only one LED is lit at a time. I thought the latches would cause one whole layer to be lit at a time, shifting between the three - not just one LED?
I'm not that good with codes yet, so i can't identify the spot, which causes this.

The first picture is 1/10 s, while the second is 1/4000 s (sorry about the total darkness).

gzip (author)  J.W.N.R.7 months ago
You're correct that the LEDs are lit one at a time. There's no latch involved though. One reason for the flicker is that most of the methods call lightSequence, which in turn calls lightPulse (on then off).

The code could probably be rearranged to light an entire level at a time by activating each column pin first (and leaving them in that state) then enabling the transistor pin; somewhat like the latch you describe.

Some flicker would still remain between levels but it could be further reduced through direct port manipulation rather than go through the Arduino API (which performs a lot of extra logic).
7 months ago

Thanks for the answer. That explains it all, then. Still have a hole lot to learn.

SamihaS7 months ago

I am completely new to arduino and even with the given code, I am unable to upload and run it. Some help would be appreciated!

7 months ago

Arduino: 1.5.8 (Windows 7), Board: "Arduino Uno"

C:\Users\Samiha\AppData\Local\Temp\build3058240577403485459.tmp/core.a(main.cpp.o): In function `main':

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:40: undefined reference to `setup'

C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `loop'

collect2: error: ld returned 1 exit status

Error compiling.

Thank you for the instructable! I was able to make an awesome working cube, and uploaded your library without a hitch. However, I was playing with the new web UI, and I keep getting the following errors when trying to upload the example to the Arduino. I have copied and pasted the entire example at the url below into a new sketch, and I still get these errors:

https://github.com/gzip/arduino-ledcube/blob/maste...

ledcube.pde: In function 'void loop()':

ledcube:49: error: 'cubeFrame' was not declared in this scope

ledcube:49: error: 'f' was not declared in this scope

ledcube:49: error: expected primary-expression before ']' token

ledcube:49: error: expected primary-expression before '{' token

ledcube:49: error: expected `;' before '{' token

ledcube:196: error: expected `}' at end of input

----------

Any suggestions?

gzip (author)  hackchip9 months ago

Hi hackchip. It sounds like you may be using the new example from github with the old library from the zip file. But aside from that I still got a different compiler error with the latest Arduino IDE (it's been a while since I last compiled this). I committed a fix for that just now and created a new zip. Try downloading the library again in step 4 and let me know how it goes. Thanks for the report.

8 months ago

Thank you! Works perfectly now. I made a beat detector circuit and am now trying to integrate the two. This is too much fun :)

bossingb9 months ago

got it.. thnx... took me a day to figure out the errors produce by the Arduino IDE. I don't know if i am the only one experiencing about the code not compiling. this what i did and solve the problem.

2.) Copy only the libraries (Ledcube.h and the other files) and paste it inside the library of your arduino.

4.) now open Arduino IDE and goto file and click open. Locate and open the Example folder of Ledcube then click the code.

thats it,,, it runs on me after different trials and errors.

stringstretcher9 months ago

One more update: I have added a 10 position rotary switch on analog 0 using switchCase that lets me select which routine to run, like a channel selector. Makes things interactive, always fun for visitors. Now I can create a series of sequences using your editor and select one to run over and over, or run the entire combination of sequences. Next I will try different ways of selecting the sequence, using different sensors.

gzip (author)  stringstretcher9 months ago

Nice touch with interactivity! Keep us posted with the results of different sensors.

TerrenceJ12 months ago

G'day, made this little 3x3x3 led cube today and thanks to you guys it worked perfectly first try, I did change it a bit but only on the circuit side and I used little high speed transistors to carry all the LED current so the UNO only switched the transistors, just wanted to play with the transistors as well, no other reason really. Anyway thanks to all on this site.

Thanks for the tutorial. Worked from the start :) I thought it will be fun to use LED in RGB color grid to make it look funnier :)

Andrew Reardon1 year ago
Thanks! It looks so cool!
baitun1 year ago
This library doesn't work for 4x4x4 cube.
cheesecurd18991 year ago
I was wondering if you could review my code, I am having a problem.
inmanster1 year ago
Been planing on making a LED cube for a while. Saw you guide here and I already had a 5x5 jig I had made, all the components and an extra Uno laying around so I followed your build and have an awesome little LED cube. I'm going to play around in the library a bit and try some new patterns.Thank you for sharing.

I may upgrade this one to a 4x4x4 or just go big and do a 8x8x8.
K5J5MTO2 years ago
Hy,
This is my first project.I fallowed the steps but I could make it light up.I am using the arduino uno and one layer green leds,one layer blue leds and one layer red leds and I am using the same parts like in the schematic.The example in the library in compile uploading to arduino board but nothing.Do I have to make some changes to arduino in the settings?
Thanks.
mastelios2 years ago
Nice instructable! just did mine! now for the bigger one..
Thumbs up!
Pog492 years ago
Hi, Nice instructable! I have used it to build a 3x3x3 cube successfully!
My question is: Can I use this method to build an 8x8x8 cube as well?
2 years ago
You'd have to use shift registers to increase the outputs of your Arduino. You also would need to make sure your pnp transistors could hold the current of 64 LEDs at one time.
whiskey_142 years ago
thanks for this!
it took about 3hrs and an extra hour trying to solder wire strands onto headers, this was one of those times you wish you'd have three hands. :)
 1-40 of 227 Next »