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

Remove these adsRemove these ads by Signing Up

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.
krezia made it!1 month ago

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 :)

Thanks! It looks so cool!
14, 10:20 AM.jpg
fforoni3 months 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.
baitun5 months ago
This library doesn't work for 4x4x4 cube.
I was wondering if you could review my code, I am having a problem.
inmanster7 months 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.
K5J5MTO8 months ago
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?
mastelios8 months ago
Nice instructable! just did mine! now for the bigger one..
Thumbs up!
Pog4911 months 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?
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_1410 months 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. :)
ironheartbj1811 months ago
download gzip frist then unzip file attached to any verison arduino/libraries click extract all file after that then you will have to same thing file as EEPROM, ENTERNET, etc. for example go to eeprom there have four file which are eeprom.h, eeprom cpp, keyboard.txt, and example that are in your in your sketch already it will showing orange letter. the ledcube does not name a type because it does not exist in your libraries. so you will have to make new folder move four files into ledcube folder.
espongy11 months ago
Hi. I just want to clarify something. I've been searching everything about building an LED Cube here in Instructables. Aren't the collectors connected to the GND while the each emitter is connected to each row/layer?
profT11 months ago
is it possible to transform your 3x3x3 led cube to 7x7x7 one. I try this and the result is not like I would! My output are not in order, how can I write them : first line (left to right) second line (left to right or right to left) etc...
and when a led sould be on it's be of and inversely, is it normal?

Gregted1 year ago
Great instructable. Worked first time. Had to find the Pin codes. They were in the arduino script but great anyway. Levels 1 pin11, 2 pin 12, 3 pin 13, and leds are pins 2 through to 10.
gzip (author)  Gregted1 year ago
Thanks. I've added a paragraph about pins to the end of step 3.
lynxhockey1 year ago
Hey, this is my first Arduino project, but I'm having some issues getting the code pushed from the sketch to the Arduino. (I'm running 1.0.4 if that matters.) However, I keep getting an error when I try to upload it that says "avrdude: stk500_getsync(): not in sync: resp=0x00" . Also, in the event that it matters, I'm using the Arduino Diecimila.
gzip (author)  lynxhockey1 year ago
You might have the wrong programmer selected or maybe it's not getting enough power.
herroc1 year ago
awesome project, took about 2hrs start to finish. No issues at all, though i would bend the legs the opposite way (as suggested). thanks
Never mind I fugured it out and it works great. However form ledcube I had to modify the ledcube.cpp file and remove the refernce to newfix.h. Until then I had problems compiling.
gzip (author)  chromedome451 year ago
What were the compile errors and what version of the Arduino software?
One more question where do you apply power? to what pins?
Question about the Transistors. Is the Emitter being grounded. Looks that way.
thank you so much, that worked for me!!! hehe :)
can you please help me in connecting the wires from the led to the the ports on an adruino?

i have very little knowledge on which port to connect thee pins from the led to the adruino
antisubae1 year ago
I fiddled with the design a little and crammed it on to a Seeed ProtoShield today. Not my best work, aesthetically, but it worked like a champ on the first try! I'm no stranger to a soldering iron, but I'm *really* new to the Arduino. It's projects like this that are really motivating me to learn the software side of things. Thanks for the awesome Instructable, gzip!
maikmuc1 year ago
Hey nice cube :-)
First I wanted to write my own library, but am not so fit yet... So I try to understand Yours and am playing around with Your code.
In the function LedCube::lightDrop I found an error since the column on Pin 10 never lights up. The parameter where You call lightPulse has to be (r-1, col, wait)
and not lightPulse(r-1, col-1, wait);
and I also wrote a function called lightRise so You can do a random column rise:

void LedCube::lightRise(byte col, unsigned int wait)
     for(byte r=0; r<=levels; r++)
        lightPulse(r-1, col, wait);
gzip (author)  maikmuc1 year ago

Please try the latest on Github:

And feel free to submit a pull request for the new method (or the bug if it's still present).
Eduort1 year ago
Hi, it looks very good, but i have a question, is posible to add more routines and start each whit a button?
fueler3351 year ago
AWESOME work on the library! Thanks so much for the transition from a 4 by 4 by 4 cube to a 3 by 3 by 3.I did this for a school project and got an A from it.Great website,as well... :)
bubzyg1 year ago
I have written an alphabet for this project, if anyone is interested in the code please let me know :)
bubzyg bubzyg1 year ago

code is inefficient as the arrays are defined each time the loop runs, this is just to move them through the "planes" with a bit of work, this can be rectified.
some coding knowledge may be required.
Hi, can i get code for an alphabet ?
i was going to do that after i finished a few additions/tweaks to this library. great learning experience this project turned out to be.
jtmanders1 year ago
ok so i have built my cube very similar to yours and the code works on it. however my cube is would i go about changing the code so it would run the entire cube? is this even possible? thanks
gzip (author)  jtmanders1 year ago
This is a work in progress so let me know if you have any luck with it.
Arduino LED Cube code
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.
Thanks for the code!!
hampp8901 year ago
Can anyone help me i have tried everything to upload the code to my Arduino Uno, and nothing seems to be working. I have unzipped the files into libraries and examples but I still get the same error code. (ledcude does not name a type) If anyone could help me that would be great.
mnralhajj1 year ago

hi,, thank u for your efforts,, i did every thing right but when i download the library an error occurred :

at LedCube cube(SIZE, levelPins, colPins); i get this error :

'LedCube' doesn't name a type

Get More Out of Instructables

Already have an Account?


PDF Downloads
As a Pro member, you will gain access to download any Instructable in the PDF format. You also have the ability to customize your PDF download.

Upgrade to Pro today!