## Step 3: Build the Circuit

The circuit is pretty simple. Each of the nine columns will connect to a pin on the Arduino through a current limiting resistor. Each of the three levels connects to ground via a NPN transistor when activated by an Arduino pin.

We'll be using 12 output pins total on the Arduino but there are 18 LEDs to power. The trick is that only a single level can be lit at a time. When a level is connected to ground, each of the LEDs on that level can be powered individually through one of the nine other Arduino pins. If we light the levels fast enough it will appear as if all three levels are lit at the same time.

Let's build the circuit.

The first step is to prepare the nine current limiting resistors. I'm using 220 ohms per pin which will draw around 22mA. The value may vary depending on the LEDs that are being used but stay between about 135 and 470 ohms. Each pin is capable of sourcing up to 40mA.

In order to save room we want to solder the resistors in a vertical position. Bend one lead down so that both leads are parallel to each other. Do this for all nine of the resistors.

Once the resistors are ready we'll solder them one by one. To make it easy we're going to solder the resistor leads directly to the other components instead of using a separate wire for each. One end of the resistor will connect to a column and the other will connect to a header. Start with the first row of LEDs which is closest to the resistors and work your way back.

Once each row is finished you can use a small piece of tape to isolate the overlapping leads in order to prevent a short. Refer to the photos and diagram to see what this will look like once it's finished.

Now that the columns are out of the way, the next step is to solder the components which control the levels. The base of a NPN transistor will be activated by an Arduino pin through a current limiting resistor of 10k (or thereabouts). This will connect the corresponding level to ground which will allow current to flow through the LEDs. Refer to the photos and diagram.

Once complete the LEDs should connect to pins 2-10 on the Arduino and the levels should connect to pins 11-13, bottom to top. The pins are also configurable in the software if you need a different setup.

The circuit is now complete, time to move on to the software!

<p>In your README file you state you have recently introduced an online UI for programming these routines... any link? I still love mine.</p>
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. :)<br> <a href="https://rawgit.com/gzip/arduino-ledcube/master/ui/index.html" rel="nofollow">https://rawgit.com/gzip/arduino-ledcube/master/ui/index.html</a>
<p>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 &quot;wow!&quot; </p>
<p>I was so excited when it actually worked first go!</p><p>Thanks for a great build!!</p>
<p>Hi<br>here is my cube :) nice colors dancing to nice music :)</p><p>https://youtu.be/aTCMM69AQs8</p>
<p>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:</p><p><a href="https://github.com/gzip/arduino-ledcube/blob/master/examples/ledcube/ledcube.pde#L48" rel="nofollow">https://github.com/gzip/arduino-ledcube/blob/maste...</a></p><p><br>ledcube.pde: In function 'void loop()':</p><p>ledcube:49: error: 'cubeFrame' was not declared in this scope</p><p>ledcube:49: error: 'f' was not declared in this scope</p><p>ledcube:49: error: expected primary-expression before ']' token</p><p>ledcube:49: error: expected primary-expression before '{' token</p><p>ledcube:49: error: expected `;' before '{' token</p><p>ledcube:196: error: expected `}' at end of input</p><p>----------</p><p>Any suggestions?</p>
<p>thnks bro</p>
<p>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.</p>
<p>Thank you! Works perfectly now. I made a beat detector circuit and am now trying to integrate the two. This is too much fun :)</p>
<p>Can't believe it worked as soon as I plugged it in and loaded software! Put transistors on breadboard for v1 since this was my first go at any major soldering. Wasn't convinced it was even going to work with my crazy soldering job. Thanks for the helpful tutorial!! Been wanted to have a go at an LED cube for ages.</p>
<p>Works! I had great fun building this.</p><p>Thanks for great instructions and code!</p>
<p>Great project! Thanks for the code! I fit everything on a smaller (19x19 holes) perfboard.</p>
<p>hi i saw one build in witch the guy said it would be ok not to use the transistor can i do it here, can someone respond please!</p>
<p>The transistors are required to light one level at a time. They are not optional.</p>
<p>A bit messy with all those wires, but it's done!</p>
<p>Can somebody tell me which pin i have to connect with which pin on the arduino</p>
<p>Great tutorial.</p><p>For the &quot;Lights Out&quot; function, has anyone experienced the following symptoms?</p><p>+ Constant flicker when the LED is on.</p><p>+ Only 3/4 of the LED go off before the function resets back to a full cube.</p><p>If so, any thoughts on the the cause and/or tweaks to fix? </p><p>Thanks.</p><p>Arduino IDE v.1.6.5; Windows 8.1, Mini Pro 5V; Experience: White Belt :)</p>
<p>How can I solve this Error:</p><p>ledcube.pde: In function 'void loop()':<br>ledcube.pde:49:57: error: taking address of temporary array<br>ledcube.pde:50:57: error: taking address of temporary array<br>ledcube.pde:51:57: error: taking address of temporary array<br>ledcube.pde:52:57: error: taking address of temporary array<br>ledcube.pde:53:57: error: taking address of temporary array<br>ledcube.pde:54:57: error: taking address of temporary array<br>ledcube.pde:55:57: error: taking address of temporary array<br>ledcube.pde:56:57: error: taking address of temporary array<br>Error compiling.</p>
I used an Arduino pro mini. The acrylic case is the package from an HDMX speaker.
<p>my upper two lavel is not so much light. and down level number nine led is not so much light.</p>
<p>I downloaded your code and library. I enjoyed the soldering but these errors come up when I compile the example given:</p><p>ledcube:15: error: 'LedCube' does not name a type<br>ledcube.pde: In function 'void loop()':<br>ledcube:49: error: 'cubeFrame' was not declared in this scope<br>ledcube:49: error: 'f' was not declared in this scope<br>ledcube:49: error: expected primary-expression before ']' token<br>ledcube:49: error: expected primary-expression before '{' token<br>ledcube:49: error: expected `;' before '{' token<br>ledcube:196: error: expected `}' at end of input</p>
<p>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.</p>
<p>Hi,there could please give the answer step by step as i am really new to this . Would appriciate the help.</p>
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.
<p>also it is Red Red Brown</p><p>gold is +- 5%</p>
<p><a href="http://www.digikey.com/en/resources/conversion-calculators/conversion-calculator-resistor-color-code-4-band" rel="nofollow">http://www.digikey.com/en/resources/conversion-cal...</a></p><p>use for any resistors</p>
<p>that's my erreur :( help pleaz</p>
I did it! It took me about 5 hours to build everything (more some extra hours to buy the NPN transistors that I missed). <br> <br>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. <br> <br>My next project is a 4x4x4 LED Cube using 3mm diffused LEDs. Maybe i'll post a step-by-step here on Instructables.
<p>Please do! I understand that bigger is much harder, even by 1 in each direction.</p>
<p>So when exporting the code, which option do i choose? Height depth width, or depth height width?</p><p>I intend on making this, and i look forward to seeing the end result!</p>
<p>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?<br>I'm not that good with codes yet, so i can't identify the spot, which causes this.</p><p>The first picture is 1/10 s, while the second is 1/4000 s (sorry about the total darkness).</p>
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).<br><br>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.<br><br>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).
<p>Thanks for the answer. That explains it all, then. Still have a hole lot to learn.</p>
<p>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!</p>
<p>Arduino: 1.5.8 (Windows 7), Board: &quot;Arduino Uno&quot;</p><p>C:\Users\Samiha\AppData\Local\Temp\build3058240577403485459.tmp/core.a(main.cpp.o): In function `main':</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:40: undefined reference to `setup'</p><p>C:\Program Files (x86)\Arduino\hardware\arduino\avr\cores\arduino/main.cpp:43: undefined reference to `loop'</p><p>collect2: error: ld returned 1 exit status</p><p>Error compiling.</p>
<p>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.</p><p>1.) after downloading the code from github, extract it.</p><p>2.) Copy only the libraries (Ledcube.h and the other files) and paste it inside the library of your arduino.</p><p>3.) copy the Example folder from the extracted downloaded file. and paste it in your documents.</p><p>4.) now open Arduino IDE and goto file and click open. Locate and open the Example folder of Ledcube then click the code.</p><p>thats it,,, it runs on me after different trials and errors. </p>
<p>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. </p>
<p>Nice touch with interactivity! Keep us posted with the results of different sensors.</p>
<p>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.</p>
<p>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 :)</p>
Thanks! It looks so cool!
This library doesn't work for 4x4x4 cube.
I was wondering if you could review my code, I am having a problem.
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. <br> <br>I may upgrade this one to a 4x4x4 or just go big and do a 8x8x8.
Hy, <br>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? <br>Thanks.
Nice instructable! just did mine! now for the bigger one.. <br>Thumbs up! <br>
Hi, Nice instructable! I have used it to build a 3x3x3 cube successfully! <br>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.
thanks for this! <br>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. :) <br>
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.